in reply to Re: How to Get Full Path Name on Win32 System
in thread How to Get Full Path Name on Win32 System

Thanks, bart. I just tried your first example and it worked just fine. Though I think I like the Cwd approach from FunkyMonk a little better.

You wrote "...you should be careful when using File::Find mixing $File::Find::name with starting out from a relative path for the root directory: File::Find chdirs to the directory the file is in, for the callback, so the proper relative path there is in $_, not in $file::Find::name. Of course, it's a whole other ballgame when you start out from absolute paths."

Good info. I appreciate it. I tried quite a variety of 'test cases' and all worked much better, as you note, with absolute paths than relative paths.

You also noted that:

"...There's a chance the formatting of the full path is still is not exactly the same as you expect from Windows: there could be a mixture of slashes or backslashes, or the case may not the same as the case for the real physical file/directory names. To fix both these issues, you can use GetLongPathName from Win32, which is a standard library on ActivePerl/Windows."

There's a nice tutorial on just that point. It has a couple of nice Regex that can be used to go back and forth between the Win32 path separator and the Perl version (forward slash). I haven't tried the GetLongPathName from Win32, but I'll sure check it out. Again, thanks.

ack Albuquerque, NM
  • Comment on Re^2: How to Get Full Path Name on Win32 System

Replies are listed 'Best First'.
Re^3: How to Get Full Path Name on Win32 System
by bart (Canon) on Mar 12, 2008 at 11:55 UTC
    GetLongPathName returns the case for the file paths as it is physically stored on disk — Windows path file names are case insensitive, but sometimes you want this exactly right.

    Note that there are also a few more related functions in that module, like for converting between long filenames (may contain spaces, can be longer than 8.3) and the 8.3 DOS compatible filenames.