[Win32utils-devel] Normalized Dir.pwd

Heesob Park phasis at gmail.com
Mon May 4 02:48:44 EDT 2009


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?

Regards,

Park Heesob


More information about the win32utils-devel mailing list