[Win32utils-devel] Normalized Dir.pwd

Daniel Berger djberg96 at gmail.com
Mon May 4 17:57:40 EDT 2009


On Mon, May 4, 2009 at 12:48 AM, Heesob Park <phasis at gmail.com> wrote:
> Hi all,
>
> I think Dir.pwd should return a normalized uniform path name
> regardless of short or long path name.
>
> Current behaviour:
>
> C:\work>irb
> irb(main):001:0> Dir.chdir('c:/PROGRA~1')
> => 0
> irb(main):002:0> Dir.pwd
> => "c:/PROGRA~1"
> irb(main):003:0> Dir.chdir('c:/PROGRAM FILES')
> => 0
> irb(main):004:0> Dir.pwd
> => "c:/PROGRAM FILES"
> irb(main):005:0> Dir.chdir('c:/Program Files')
> => 0
> irb(main):006:0> Dir.pwd
> => "c:/Program Files"
>
> Suggested behaviour:
>
> C:\work>irb -r 'win32/dir'
> irb(main):001:0> Dir.chdir('c:/PROGRA~1')
> => 0
> irb(main):002:0> Dir.pwd
> => "c:\\Program Files"
> irb(main):003:0> Dir.chdir('c:/PROGRAM FILES')
> => 0
> irb(main):004:0> Dir.pwd
> => c:\\Program Files"
> irb(main):005:0> Dir.chdir('c:/Program Files')
> => 0
> irb(main):006:0> Dir.pwd
> => c:\\Program Files"
>
> Here is a draft pwd for win32/dir
>
>   def self.pwd()
>      path    = 0.chr * MAXPATH
>      path2   = 0.chr * MAXPATH
>      path3   = 0.chr * MAXPATH
>      GetCurrentDirectory(MAXPATH,path)
>          GetShortPathName(path,path2,MAXPATH)
>          GetLongPathName(path2,path3,MAXPATH)
>          path3[/^[^\0]*/]
>   end
>
> What do you think about this?

Looks good to me. Please create a feature request and I'll add the
change for the next version. :)

Speaking of win32-dir, do you have any idea regarding this issue?

http://rubyforge.org/tracker/index.php?func=detail&aid=21110&group_id=85&atid=412

Regards,

Dan


More information about the win32utils-devel mailing list