S
Siva Prakasam
how to write a file before its EOF
by giving some position .
by giving some position .
how to write a file before its EOF
by giving some position .
how to write a file before its EOF
by giving some position .
Paul said:You do understand that if you write to a file at an arbitrary position,
it
will overwrite was was there before, yes? A insertion, if that is what
you
actually have in mind, is a bit more complicated (but that can also be
done).
Look at IO:seek.
Gabriele Marrone said:File.open("mylog.txt", "a") do |f|
f.puts "adding this line at the end"
end
You'll have to make a new file. Copy the old file contents up to theSiva said:yes, i want to insert a file without overwriting its existing content.
i looked for IO:SEEK_CUR and IO:SEEK_SET which will set the position.but
it overwrites the existing content. how to do that?
It depends on how big the file is and how lazy a programmer you are. ForTimothy said:You'll have to make a new file. Copy the old file contents up to the
point you want to insert the new material, insert the new material,
then copy the remainder of the old file. After the new file is safely
closed, delete the old file.
Paul Lutus said:Answer number one: why don't you find out by doing an experiment? Surely you
don't expect to be able to develop software for a particular operating
system without actually doing tests on that OS, do you?
Answer number two: yes, it works on Windows. It is a tautology of file
processing, and if it did not work, there wouldn't be anything else
discussed on this newsgroup.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.