[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Problem with seeking in existing files.

Thomas Morgan

10/30/2003 6:42:00 AM

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. I am using sysread
and syswrite to work with the file.

The problem is that seek doesn't seem to work. At
first I thought it might be regarding the end of the
original file as the 0 point, but some more testing
showed that even with an empty file, seek was not
changing the position of the file pointer.

I did some tests in IRB with a file opened with the
same mode, and seek seemed properly in it. Changing
the mode in the program to 'ab' did not work. (And I'm
eventually going to need read-write capability
anyway...)

Anyone know what could be causing this problem?

-Morgan.

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/brit...

1 Answer

matz

10/30/2003 8:34:00 AM

0

Hi,

In message "Problem with seeking in existing files."
on 03/10/30, agemoagemo@yahoo.com <agemoagemo@yahoo.com> writes:

|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. I am using sysread
|and syswrite to work with the file.

I don't know what platform you are working on. But in general, stdio
does not work well with "a" (append) mode and seeking. It's stdio
restriction.

matz.