Apologies for the delay in replying, I was on vacation.

"Möllenbeck, Martin" wrote, in part:
if i use your the function 'rootdir' from the modul 'File::Spec' on Win32,
the function return only '/'. I expect a list of drives like ('A:', 'C:', 'D:').
To be pedantic, those are volume names not directories. &rootdir returns the
local OS's symbology for the root directory. The only place that this is
not quite true is where there is no equivalent to a root directory. On
MacOS the top directory of the startup volume is returned. On VMS, a similar
thing is done. If we were to do this on MSDOSish systems, we'd need to use
either the boot drive or the current drive, but not return a list. Either
way would break existing code.
Here ist my proposal:

Modul 'File::Spec::Win32'

sub rootdir {
require Win32API::File;
my @root_drives = Win32API::File::getLogicalDrives();

return wantarray ? @root_drives: join(' ', @root_drives);

Maybe can you change it in the next release?
Sorry, can't do that.
I think it's more portabel.
Not really: lots of scripts out there would suddenly act differently or
cease working. Something as simple as

File::Spec->catfile( File::Spec->rootdir(), 'foo.txt' ) ;

wouldn't work (that would probably return 'A:/C:/D:/foo.txt'). Even if
it were to return "C:/foo.txt", programs that rely on the current
behavior when running on some other volume would break.

Most unix-under-MSDOSish execution environments assume that you are staying
on the currently selected volume, just like normal MSDOSish programs do. Some,
like some Win32 perls, allow you to use a drive letter if you like, but don't
require it. So, MSDOSish paths work as expected, as do Unix paths. Just don't
expect a Unix-native program to handle volume names properly in the face of
things like '..', etc. And don't even get me started on UNC and '..'.

I would not mind seeing a way of listing all available volumes in File::Spec,
but I don't think rootdir() is the place for it.

- Barrie

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
postedJul 9, '00 at 9:24a
activeJul 9, '00 at 9:24a

1 user in discussion

Barrie Slaymaker: 1 post



site design / logo © 2022 Grokbase