|
Re: Getting the file name from a File::Stat object?: msg#00795lang.ruby.general
At Fri, 9 Aug 2002 22:46:32 +0900, Lloyd Zusman wrote: > Is there a way to get the file name from a File::Stat object? Only way is to search files which have the inode number File::Stat#ino. File::Stat represents status of an inode and an inode may be associated many file names. % mkdir foo % cd foo % touch a % ln a b % ln a c % ls -i 2032361 a 2032361 b 2032361 c % ruby -e 's = %w(a b c).map{|i| File.stat(i)}; p [s[0]==s[1], s[1]==s[2]]' [true, true] % touch d % ls -i 2032361 a 2032361 b 2032361 c 2032364 d % find . -inum 2032361 ./a ./b ./c % ruby -r find -e 'a = File.stat("a"); Find.find("."){|i| puts i if File.stat(i).ino == a.ino}' ./c ./b ./a % But you might need to do Find.find("/") instead of Find.find("."). -- Gotoken
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Ruby in EETimes, Rich Kilmer |
|---|---|
| Next by Date: | Are All C Destructors Guaranteed to Be Called?, William Djaja Tjokroaminata |
| Previous by Thread: | Getting the file name from a File::Stat object?, Lloyd Zusman |
| Next by Thread: | Re: Getting the file name from a File::Stat object?, Lloyd Zusman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |