From: Greg Willits Date: 2009-07-06T02:08:11+09:00 Subject: Re: file.seek and unused bytes Brian Candler wrote: > Eleanor McHugh wrote: >>> Can I count on those unused bytes always being zero? >> >> Unfortunately you're getting lucky. A seek adjusts the file pointer >> but doesn't write anything to disk so whilst your 'unused' bytes won't >> be changing value as a result of writing data to the file unless you >> write the full record, you can't rely on them not having a value other >> than zero if you don't. > > I don't believe that's the case today. If it were, then you would have a > very easy way to examine the contents of unused sectors on the disk - > which would allow you to see other people's deleted files, passwords > etc. > > It was possible on old mainframe systems in the 80's though :-) 80's micros too with BASIC :-P > But today, if you extend a file using seek, you should always read > zeros. That makes a great deal of sense, and would be consistent with what I was seeing. I was wondering why the values being returned were zeros instead of nil or something else. Either way, I know its a better practice to pack the rows, but I had a moment of laziness because I'm dealing will a couple million rows and figured if there was some processing time to be saved, I'd take advantage of it. I would have experimented, but I don't know how to ensure that the various file contents are in fact being written to the exact same disk space. -- gw -- Posted via http://www.ruby-forum.com/.