Upgrade to File::Spec 0.85.
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Mac.pm
index c3ae7af..513e837 100644 (file)
@@ -4,11 +4,18 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '1.3';
+$VERSION = '1.4';
 
 @ISA = qw(File::Spec::Unix);
 
 use Cwd;
+my $macfiles;
+if ($^O eq 'MacOS') {
+       $macfiles = eval { require Mac::Files };
+}
+
+sub case_tolerant { 1 }
+
 
 =head1 NAME
 
@@ -339,6 +346,8 @@ concept, although other volumes aren't rooted there. The name has a
 trailing ":", because that's the correct specification for a volume
 name on Mac OS.
 
+If Mac::Files could not be loaded, the empty string is returned.
+
 =cut
 
 sub rootdir {
@@ -346,29 +355,27 @@ sub rootdir {
 #  There's no real root directory on Mac OS. The name of the startup
 #  volume is returned, since that's the closest in concept.
 #
-    require Mac::Files;
-    my $system =  Mac::Files::FindFolder(&Mac::Files::kOnSystemDisk,
-                                        &Mac::Files::kSystemFolderType);
+    return '' unless $macfiles;
+    my $system = Mac::Files::FindFolder(&Mac::Files::kOnSystemDisk,
+       &Mac::Files::kSystemFolderType);
     $system =~ s/:.*\Z(?!\n)/:/s;
     return $system;
 }
 
 =item tmpdir
 
-Returns the contents of $ENV{TMPDIR}, if that directory exits or the current working
-directory otherwise. Under MacPerl, $ENV{TMPDIR} will contain a path like
-"MacintoshHD:Temporary Items:", which is a hidden directory on your startup volume.
+Returns the contents of $ENV{TMPDIR}, if that directory exits or the
+current working directory otherwise. Under MacPerl, $ENV{TMPDIR} will
+contain a path like "MacintoshHD:Temporary Items:", which is a hidden
+directory on your startup volume.
 
 =cut
 
 my $tmpdir;
 sub tmpdir {
     return $tmpdir if defined $tmpdir;
-    $tmpdir = $ENV{TMPDIR} if -d $ENV{TMPDIR};
-    unless (defined($tmpdir)) {
-       $tmpdir = cwd();
-    }
-    return $tmpdir;
+    my $self = shift;
+    $tmpdir = $self->_tmpdir( $ENV{TMPDIR} );
 }
 
 =item updir
@@ -436,7 +443,7 @@ sub path {
     ($volume,$directories,$file) = File::Spec->splitpath( $path );
     ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file );
 
-Splits a path in to volume, directory, and filename portions.
+Splits a path into volume, directory, and filename portions.
 
 On Mac OS, assumes that the last part of the path is a filename unless
 $no_file is true or a trailing separator ":" is present.