From: Alan Davies Date: 2003-09-23T01:30:22+09:00 Subject: Re: File.expand_path and ~ on windows Sean O'Dell wrote: > Tom Felker wrote: > >> On Thu, 18 Sep 2003 17:16:00 +0100, Alan Davies wrote: >> >> >>> From the pickaxe book... >>> >>> > File.expand_path( fileName [, aDirString ] ) -> fileName >>> >>> > The given pathname may start with a ``~'', which expands to the >>> > process owner's home directory (the environment variable HOME must be >>> > set correctly). "~ user" expands to the named user's home directory" >>> >>> This isn't relevant on windows. Thus: >> >> >> >> Wouldn't it make more sense to expand it to My Documents (C:\Documents >> and >> Settings\Username\My Documents on WinXP)? I suppose it would be >> worthwhile to be able to disable it, though. > > > Actually, I think it should just expand to C:\Documents and > Settings\UserName and you can append the rest from there. That's the > *nix equivalent pretty much. > > Sean O'Dell > Some interesting points being made on this thread, but the problem I had was that I has a files beginning with ~ in my temp folder. Using expand_path to get the full path of these files failed. If it expanded it to user directories, then it woulod be returning incrrect path names, simply because ~ has no meaning on windows. If I have a file called ~foo in a dir called "c:/somedir", then I would expand_path to return "c:/somedir/~foo", not "C:/Documents and Settings/foo" Alan.