This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: Redefining File methods
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Well, it looks like the proposed Pathname changes are dead. Wah.
One good thing to come out of it, however, is that Austin Ziegler rightly pointed out that File.basename and File.dirname don't work properly on Win32 with regards to UNC paths.
Well, if I can't fix Pathname, at least I can fix the File methods. So, as of today's release of the win32-file package (0.4.3) those methods work properly. There are now a total of six* methods I've had to define or redefine to make them work properly:
* File.size - current implementation doesn't handle file sizes > 2 GB * File.chardev? - current implementation (falsely) always returns false * File.blockdev? - ditto * File.basename - UNC paths not handled properly * File.dirname - ditto * File::Stat.blksize - not implemented in core Ruby for Win32
The big one still left, however, is File.stat, which only partially works on Win32 systems because it uses the 'etc' package internally (which doesn't work on Windows). So, some of the File::Stat struct members contain bogus information, or no information at all.
Onward.
* Ok, technically it's +seven+ methods. I don't count File.path, however, because I redefined it for internal reasons only, and the behavior is identical.