From: Roger Pack Date: 2009-02-22T00:49:05+09:00 Subject: [ruby-core:22313] Re: File#size et al > In message "Re: [ruby-core:22088] File#size et al" > on Sun, 15 Feb 2009 03:26:09 +0900, Roger Pack writes: > > |In a recent discussion[1] on some more "convenience" methods for File, > |it seems that quite a few methods would be convenient for it > | > |File#size # does a stat.size or a flush then a size. > > Currently we have File#stat and #atime, #mtime, #ctime. What else do > you think we need? Besides that requirement for flushing may vary > methods to methods. > > |A few things that would be nice: > |1) more methods on an existing file > > Please more concrete. What kind of methods, with what concrete > behavior? Well I'm not saying the current setup doesn't work, or trying to be offensive or anything. I am trying to make the File class more user friendly. Currently to get a file size you call foo.stat.size. This does not work for files whose buffers have not been flushed. You have to use tell for files that you are writing to, and stat.size for files you aren't. tell however, does not give you the filesize if you have seeked back to the middle of a file. If you grep the methods of an open file for the /size/, it returns []. I was suggesting a more unified File#size method [call flush, return stat.size]. Another commentor also noted that there is no File#dirname #absolutepath etc., which methods would also be nice, but, well, probably not as useful :P Mostly size is what I'm talking about. I could suggest a few other [non related] things but I think we can stick with these for now. Thanks! -=r