[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Problem with seeking in existing files.

Warren Brown

10/30/2003 3:59:00 PM

Morgan,

> I'm trying to write a program that will be writing
> data to an existing file, that will not necessarily
> be done in the physical file order. I used mode
> 'ab+' to open the file, as only the 'a' modes allow
> writing without changing the existing file.

It sounds like what you really want is to open the file with a mode
of 'r+b'. This allows reading and writing of the file without
truncating the file (like 'w+b'). As you mentioned, a mode of 'ab'
opens the file for writing only (at end of file). To open for reading
and writing (at end of file) you would need a mode of 'a+b'. I believe
a mode of 'ab+' is technically incorrect on most platforms, although it
may work on some.

I hope this helps!

- Warren Brown