On Sun, Sep 11, 2011 at 4:48 AM, Nobuyoshi Nakada <nobu / ruby-lang.org> wrote: > Hi, > > At Sun, 11 Sep 2011 00:58:53 +0900, > Luis Lavena wrote in [ruby-core:39451]: >> My question: can this behavior be changed for Windows? >> >> Asking this because we are not reading and resolving symlink, >> junctions or hardlinks in Ruby for Windows, so doing the entire >> traversal and check seems a bit expensive (several stat() calls) > > I think resolving symlinks and junctions should be implemented > in the future. > Perhaps for Ruby 2.0, because introducing such change right now will result in lot of problems. Right a symlink *is* a reparse point, like junctions and these can be pointing to different driver letters or network shares. Problems: 1) Current symlink functionality requires not only Vista or greater but also elevation of privileges to create them. 2) Some directory symlinks can point to UNC paths or other drive letters. > # "Resolving hardlinks" makes no sense on any platforms. > >> This means: build absolute path, expand if required, combine with >> GetFileAttributesEx to check for existance. > > Is this what you want? > > ¨Βιμε®στατ¨αβσομυτείπατθ Ζιμε®αβσομυτείπατθ¨πατθίξανε©©αβσομυτείπατ> Something similar, mainly because File.absolute_path is performing a FindFirstFileA (globbing operation to resolve shortnames using ANSI) and then winnt_stat() is doing FindFirstFileW (another globbing operation) to obtain stats: API Duration GetCurrentDirectoryA ( 0, NULL ) 0.0000056 GetCurrentDirectoryA ( 200, 0x02cb3f00 ) 0.0000056 FindFirstFileA ( "V:/a/b/d/e/foo.rb", 0x0028e980 ) 0.0002077 FindClose ( 0x00773930 ) 0.0000583 FindFirstFileW ( "V:\a\b\d\e\foo.rb", 0x0028e7d0 ) 0.0000901 FindClose ( 0x00773930 ) 0.0001246 === From what I see here, neither File.absolute_path or File.expand_path should be performing FS-operations (they don't on UNIX), the only one that does is File.realpath because it resolves symlinks. I want zero operations for File.expand_path and File.absolute_path while keeping File.realpath to a moderate number, current implementation: (given V:\a\b\c\d\e\foo.rb exists): >> File.realpath("foo.rb") => "V:/a/b/d/e/foo.rb" Produces: API Duration GetCurrentDirectoryA ( 0, NULL ) 0.0000061 GetCurrentDirectoryA ( 200, 0x02cb3f00 ) 0.0000061 FindFirstFileW ( "V:\a", 0x0028e6e0 ) 0.0001736 FindClose ( 0x00773930 ) 0.0000509 FindFirstFileW ( "V:\a\b", 0x0028e6e0 ) 0.0000798 FindClose ( 0x00773930 ) 0.0000387 FindFirstFileW ( "V:\a\b\d", 0x0028e6d0 ) 0.0000737 FindClose ( 0x00773930 ) 0.0000392 FindFirstFileW ( "V:\a\b\d\e", 0x0028e6d0 ) 0.0001680 FindClose ( 0x00773930 ) 0.0000387 FindFirstFileW ( "V:\a\b\d\e\foo.rb", 0x0028e6c0 ) 0.0000784 FindClose ( 0x00773930 ) 0.0000378 -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-ExupρΣy