IO#pos not reporting correctly for files in append mode?

E

Erik Hollensbe

Let's say there is a file, 'foo', which contains some text already:

f = File.open("foo", "a")
f.pos => 0 #?!?!?!
f.seek(0, IO::SEEK_END)
f.pos => correct

Now, according to the IO documentation:

"a" | Write-only, starts at end of file if file exists,
| otherwise creates a new file for writing.

This leads me to believe that IO#pos should be set to something other
than 0 if the file contains data already. Is there something wrong with
my assumption, or is this a bug (and if so, is it already known?)

I am using Ruby 1.8.4 on OS X 10.4.6.

Thanks for any help! Please Cc: me personally.
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top