Perl package File::Spec confused under cygwin

Michael A Chase
Fri Dec 20 17:51:00 GMT 2002

On Fri, 20 Dec 2002 13:27:50 -0800 "linda w (cyg)" <> wrote:

> File::Spec is supposed to provide a OS independent way of parsing and
> creating pathnames.  For example, a 'splitpath' can product a volume
> $dir and $file.  

Note that Cygwin, like Unix, doesn't have a concept of volume.  Everything
except network paths (//host/dir) are based on a single root directory. 

> I'm not sure what constitutes a volume but I'd think C: D: would count
> as separate.

Mixed file specifications like c:/x/y/z are handled by many programs in the
Cygwin environment, but such paths are not really valid.  File::Spec::Win32
accepts '/' as well as '\' as a directory separator.

> Under cygwin, it only handles/parses unix pathnames but not native
> windows pathnames 'c:\windows\filename' will yield a vol='', dir='' and
> filename='d:\windows\filelname' -- not what one would expect.  Using
> forward slashes yields: vdf='', 'd:/windows/,'filename'.

That's exactly the situation.  File::Spec::Cygwin for Perl 5.8 only
overrides file_name_is_absolute() and canonpath(); other than that it's
pure File::Spec::Unix.  I'm sure the Perl Porters would be willing to
examine a patch to handle mixed specs.

> Further use to break down the directory path into components would
> yield D: as a first directory and 'windows' as a 2nd level dir. 
> Note that the forward slash has now disappeared indicating what I believe
> to be improper symantics as d:windows != D:\windows unless d:'s curdir
> is = to the root dir.

You can always call File::Spec::Win32 -> splitpath() to get that behavior.

> Guess when the module detects the OS type, it needs to have a separate
> type for the cygwin environment.

It does, but File::Spec::Cygwin is very close to File::Spec::Unix.

Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter:
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Unsubscribe info:
Bug reporting:

More information about the Cygwin mailing list