> Maybe I'm crazy, but doesn't this reliably get the length of an open
> file in C?  I used it in an emulator once upon a time ...
>   x = tell( handle );
>   file_length = lseek( handle, 0, SEEK_END );
>   lseek( handle, x, SEEK_SET );

I used it in DOS code 8 years ago. I just wrote the same thing in Ruby on 
Linux 8 minutes ago. It works, but I hesitate. Matz proposes
file.stat.size, and that seems also reasonable, but I'm not sure whether
stat works on all platforms.

The big difference between the above code and the one in ruby is that the
one in ruby uses fseek/ftell instead of seek/tell (i hope) and the former
(may) call fflush before doing their actual job; which is what Matz is
trying to do because fstat (hence File#stat) doesn't call fflush
(File#flush).

> ... hmm, yes, feel free to enlighten me on the fine distinctions between
> files and streams here...

huh? yes, I wish Ruby had a distinction between files and streams.

But then, C, or C documentation, is outright misleading, and calls "files" 
what could be called "buffered streams", unless the "f" prefix really
stands for "buFFered"... and then has other usages of "file" elsewhere...
oh, whatever. 

matju