From: Emmanuel Touzery Date: 2002-11-29T21:09:15+09:00 Subject: Re: root directory actually i think that using something like: def root?() path = Dir.pwd # **ugly** hack... Dir.chdir("..") pathUp = Dir.pwd Dir.chdir(path) return (pathUp == path) end should work on UNIX and windows (only tested under UNIX). changing temporarily the current directory is extremely ugly (think threads), but I don't see any other simple options (if i had a windows machine with ruby installed and some time however..). anything better? emmanuel On Friday 29 November 2002 09:35, Emmanuel Touzery wrote: > Hello, > > Right now I need in an application to recurse from the current dir to the > root dir in ruby. that means eg /home/emmanuel/test, /home/emmanuel, /home, > /. > I've been quick to write a Dir.up!() method (i was surprised it's not > standard?), however i'm having trouble with the Dir.root?() one. > Of course on UNIX it would be pwd == "/" and that's done, but on windows > that's another story... with c:, a: and network drives > (\\mycomputer\mydrive\mydir)... > I'm quite sure somebody already did that in ruby? I don't have a windows > computer around at home so it would be hell to get right.. > > TIA, > > emmanuel -- "Stop the world, I want to hop off!" --Guy Bedos