From: Overnight Date: 2002-09-24T05:19:14+09:00 Subject: Re: File.lib bug? > > C:\>irb > > irb(main):001:0> d=File.join('c:/','windows') > > "c://windows" > > irb(main):002:0> File.directory?(d) > > false > > irb(main):003:0> File.directory?('c:/windows') > > true > > irb(main):004:0> File.expand_path(d) > > "c:/windows" > > irb(main):005:0> File.directory?(File.expand_path(d)) > > true > I'm guessing that the reason why File.directory?(d) == false was > File.exist?(d) == false. > File.join is intended to absorb the deference of path separator among > platforms. File.join(a,b,c,d) is equivalent to > [a,b,c,d].join(File::SEPARATOR) > So, File.join('c:/', 'windows') should be File.join('c:', 'windows'). Hmmmm, imho i'd like to see this fixed... Under Unix, if I'm not wrong, something like '/usr//lib' won't hurt, but under Windows it will, as I showed in my example (btw, it looks like the presence of double slash in the argument to File.directory? makes Ruby/Windows go and look for some remote hosts, considering the long delay it takes before it returns false...) Using File.join('c:','windows') will work of course, but under Windows I never refer to the root of a disk as C:, D:, etc, always as C:\, D:\. This is an habit imposed from the shell, which interprets 'C:' (alone, with no slash) as "current working dir of disk C". So 'C:myfile' is the same as 'C:\myfile' only if the working dir of C: is '\'... Last observation: with 1.6.7, File::SEPARATOR evals to '/', and this looks definitely wrong to me (even if Ruby understands both '/' and '\' in paths). It's wonderful to see how easily such things can be fixed in Ruby, but I'd like to see them fixed officially: I guess I'm not the only one who got bitten by this... > I'm afraid documentation about 1.7 is written in only Japanese. That > is being written on an Wiki system. I'll have to wait, not ready for a Japanese quick course at the moment :- ) Thank you for your help, Andrea