From: Nobuyoshi Nakada Date: 2011-09-13T15:15:43+09:00 Subject: [ruby-core:39504] Re: File.realpath behavior questions Hi, At Sun, 11 Sep 2011 23:02:39 +0900, Luis Lavena wrote in [ruby-core:39472]: > Problems: > > 1) Current symlink functionality requires not only Vista or greater > but also elevation of privileges to create them. It's only for creation, so it'd not be a matter at resolving. > 2) Some directory symlinks can point to UNC paths or other drive letters. Sure. What's problem on it? > > # "Resolving hardlinks" makes no sense on any platforms. I was wrong here: it's necessary for security issues on Windows, because of automatically created short names. > >> This means: build absolute path, expand if required, combine with > >> GetFileAttributesEx to check for existance. > > > > Is this what you want? > > > > File.stat(absolute_path = File.absolute_path(path_name)); absolute_path > > > > 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: Ohter API results were varying across Windows versions, so FindFirstFile was the last resort for stat. > 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. The reason why they don't on UNIX is that automatically and implicitly created aliases are uncommon on UNIX. Since these come from the spec of Windows filesystem and security requirements, so it's not acceptable to change the behavior of File.expand_path, unfortunately. -- Nobu Nakada