Change 16138: Play nicely in miniperl

[email protected] (Chris Nandor) Wed, 24 Apr 2002 15:22:37 -0400
Newsgroups perl.perl5.changes.mac
Message-ID <p05100313b8ecb668b3f6@[10.0.1.177]>
Change 16138 by pudge@pudge-mobile on 2002/04/24 18:12:22

	Play nicely in miniperl

Affected files ...

.... //depot/macperl/lib/File/Copy.pm#2 edit
.... //depot/macperl/lib/File/Spec/Mac.pm#2 edit

Differences ...

==== //depot/macperl/lib/File/Copy.pm#2 (text) ====
Index: perl/lib/File/Copy.pm
--- perl/lib/File/Copy.pm.~1~	Wed Apr 24 12:15:11 2002
+++ perl/lib/File/Copy.pm	Wed Apr 24 12:15:11 2002
@@ -33,6 +33,13 @@
 
 $Too_Big = 1024 * 1024 * 2;
 
+my $macfiles;
+if ($^O eq 'MacOS') {
+	$macfiles = eval { require Mac::MoreFiles };
+	warn 'Mac::MoreFiles could not be loaded; using non-native syscopy'
+		if $^W;
+}
+
 sub _catname {
     my($from, $to) = @_;
     if (not defined &basename) {
@@ -230,8 +237,7 @@
 	    return 0 unless @_ == 2;
 	    return Win32::CopyFile(@_, 1);
 	};
-    } elsif ($^O eq 'MacOS') {
-	require Mac::MoreFiles;
+    } elsif ($macfiles) {
 	*syscopy = sub {
 	    my($from, $to) = @_;
 	    my($dir, $toname);
@@ -338,6 +344,9 @@
 systems, this calls the C<syscopy> XSUB directly. For Win32 systems,
 this calls C<Win32::CopyFile>.
 
+On Mac OS (Classic), C<syscopy> calls C<Mac::MoreFiles::FSpFileCopy>,
+if available.
+
 =head2 Special behaviour if C<syscopy> is defined (OS/2, VMS and Win32)
 
 If both arguments to C<copy> are not file handles,

==== //depot/macperl/lib/File/Spec/Mac.pm#2 (text) ====
Index: perl/lib/File/Spec/Mac.pm
--- perl/lib/File/Spec/Mac.pm.~1~	Wed Apr 24 12:15:11 2002
+++ perl/lib/File/Spec/Mac.pm	Wed Apr 24 12:15:11 2002
@@ -9,6 +9,10 @@
 @ISA = qw(File::Spec::Unix);
 
 use Cwd;
+my $macfiles;
+if ($^O eq 'MacOS') {
+	$macfiles = eval { require Mac::Files };
+}
 
 =head1 NAME
 
@@ -339,6 +343,8 @@
 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,9 +352,9 @@
 #  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;
 }
End of Patch.