Greg Willits wrote:
>> I don't think anyone has answered this question directly but on POSIX-
>> like file systems a seek past the end of the file and a subsequent
>> write will cause the intervening bytes (which have never been written)
>> to read as zeros. Whether those 'holes' occupy disk space or not is
>> implementation dependent.
> 
> 
> If in deed this is a fact (and it's consistent with my observation), 
> then I'd say it's worth taking advantage of. I can't find a definitive 
> reference to cite though (Pickaxe, The Ruby Way).

Well, those aren't POSIX references. But from "Advanced Programming in 
the UNIX Environment" by the late great Richard Stevens, pub. 
Addison-Wesley, p53:

"`lseek` only records the current file offset within the kernel - it 
does not cause any I/O to take place. This offset is then used by the 
next read or write operation.

The file's offset can get greater than the file's current size, in which 
case the next `write` to the file will extend the file. This is referred 
to as creating a hole in a file and is allowed. Any bytes in a file that 
have not been written are read back as 0."
-- 
Posted via http://www.ruby-forum.com/.