print "# \$File::Find::name => '$n'\n";
my $i = rindex($n,'/');
my $OK = exists($Expect_Name{$n});
- unless ($^O eq 'MacOS') {
- if ( $OK ) {
- $OK= exists($Expect_Name{substr($n,0,$i)}) if $i >= 0;
- }
+ if ( $OK ) {
+ $OK= exists($Expect_Name{substr($n,0,$i)}) if $i >= 0;
}
Check($OK);
delete $Expect_Name{$n};
s#\.$## if ($^O eq 'VMS' && $_ ne '.');
my $i = rindex($_,'/');
my $OK = exists($Expect_File{ $_});
- unless ($^O eq 'MacOS') {
- if ( $OK ) {
- $OK= exists($Expect_File{ substr($_,0,$i)}) if $i >= 0;
- }
+ if ( $OK ) {
+ $OK= exists($Expect_File{ substr($_,0,$i)}) if $i >= 0;
}
Check($OK);
delete $Expect_File{ $_};
# there are limitations. Don't try to create an absolute path,
# because that may fail on operating systems that have the concept of
# volume names (e.g. Mac OS). As a special case, you can pass it a "."
-# as first argument, to create a directory path like "./fa/dir" on
-# operating systems other than Mac OS (actually, Mac OS will ignore
-# the ".", if it's the first argument). If there's no second argument,
-# this function will return the empty string on Mac OS and the string
-# "./" otherwise.
+# as first argument, to create a directory path like "./fa/dir". If there's
+# no second argument, this function will return "./"
sub dir_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":" and with trailing ":"
- return File::Spec->catdir(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catdir(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catdir(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
return File::Spec->catdir($first_arg, @_); # relative path
# Use topdir() to specify a directory path that you want to pass to
-# find/finddepth. Basically, topdir() does the same as dir_path() (see
-# above), except that there's no trailing ":" on Mac OS.
+# find/finddepth. Historically topdir() differed on Mac OS classic.
-sub topdir {
- my $path = dir_path(@_);
- $path =~ s/:$// if ($^O eq 'MacOS');
- return $path;
-}
+*topdir = \&dir_path;
# Use file_path() to specify a file path that's expected for $_
# file). It's independent from the platform it's run on, although
# there are limitations. As a special case, you can pass it a "." as
# first argument, to create a file path like "./fa/file" on operating
-# systems other than Mac OS (actually, Mac OS will ignore the ".", if
-# it's the first argument). If there's no second argument, this
-# function will return the empty string on Mac OS and the string "./"
-# otherwise.
+# systems. If there's no second argument, this function will return the
+# string "./"
sub file_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":", but without trailing ":"
- return File::Spec->catfile(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catfile(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catfile(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
return File::Spec->catfile($first_arg, @_); # relative path
# case, also use this function to specify a file path that's expected
# for $_.
#
-# Basically, file_path_name() does the same as file_path() (see
-# above), except that there's always a leading ":" on Mac OS, even for
-# plain file/directory names.
-
-sub file_path_name {
- my $path = file_path(@_);
- $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
- return $path;
-}
+# Historically file_path_name differed on Mac OS classic.
+
+*file_path_name = \&file_path;
touch( file_path('fb', 'fb_ord') );
MkDir( dir_path('fb', 'fba'), 0770 );
touch( file_path('fb', 'fba', 'fba_ord') );
-if ($^O eq 'MacOS') {
- CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
-} else {
- CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
-}
+CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
touch( file_path('fa', 'fa_ord') );
MkDir( dir_path('fa', 'faa'), 0770 );
file_path('dangling_dir_sl') ) );
rmdir dir_path('dangling_dir');
touch(file_path('dangling_file'));
- if ($^O eq 'MacOS') {
- CheckDie( symlink('dangling_file', ':fa:dangling_file_sl') );
- } else {
- CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
- }
+ CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
unlink file_path('dangling_file');
{
print "# check recursion\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') );
- } else {
- CheckDie( symlink('../faa','fa/faa/faa_sl') );
- }
+ CheckDie( symlink('../faa','fa/faa/faa_sl') );
undef $@;
eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
no_chdir => 1}, topdir('fa') ); };
print "# check follow_skip (file)\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file
- } else {
- CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
- }
+ CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
undef $@;
eval {File::Find::finddepth( {wanted => \&simple_wanted,
print "# check follow_skip (directory)\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory
- } else {
- CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
- }
+ CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
undef $@;
eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
MkDir (dir_path ('fa', 'fac'), 0770);
MkDir (dir_path ('fb', 'fbc'), 0770);
touch (file_path ('fa', 'fac', 'faca'));
- if ($^O eq 'MacOS') {
- CheckDie (symlink ('..::::..:fa:fac:faca', 'fb:fbc:fbca'));
- }
- else {
- CheckDie (symlink ('..////../fa/fac/faca', 'fb/fbc/fbca'));
- }
+ CheckDie (symlink ('..////../fa/fac/faca', 'fb/fbc/fbca'));
use warnings;
my $dangling_symlink;
# there are limitations. Don't try to create an absolute path,
# because that may fail on operating systems that have the concept of
# volume names (e.g. Mac OS). As a special case, you can pass it a "."
-# as first argument, to create a directory path like "./fa/dir" on
-# operating systems other than Mac OS (actually, Mac OS will ignore
-# the ".", if it's the first argument). If there's no second argument,
-# this function will return the empty string on Mac OS and the string
-# "./" otherwise.
+# as first argument, to create a directory path like "./fa/dir". If there's
+# no second argument this function will return the string "./"
sub dir_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":" and with trailing ":"
- return File::Spec->catdir(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catdir(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catdir(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
my $fname = File::Spec->catdir($first_arg, @_); # relative path
# Use topdir() to specify a directory path that you want to pass to
-# find/finddepth. Basically, topdir() does the same as dir_path() (see
-# above), except that there's no trailing ":" on Mac OS.
+# find/finddepth. Historically topdir() differed on Mac OS classic.
-sub topdir {
- my $path = dir_path(@_);
- $path =~ s/:$// if ($^O eq 'MacOS');
- return $path;
-}
+*topdir = \&dir_path;
# Use file_path() to specify a file path that's expected for $_
# form a *relative* file path (the last argument is assumed to be a
# file). It's independent from the platform it's run on, although
# there are limitations. As a special case, you can pass it a "." as
-# first argument, to create a file path like "./fa/file" on operating
-# systems other than Mac OS (actually, Mac OS will ignore the ".", if
-# it's the first argument). If there's no second argument, this
-# function will return the empty string on Mac OS and the string "./"
-# otherwise.
+# first argument, to create a file path like "./fa/file". If there's no
+# second argument, this function will return the string "./" otherwise.
sub file_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":", but without trailing ":"
- return File::Spec->catfile(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catfile(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catfile(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
my $fname = File::Spec->catfile($first_arg, @_); # relative path
# case, also use this function to specify a file path that's expected
# for $_.
#
-# Basically, file_path_name() does the same as file_path() (see
-# above), except that there's always a leading ":" on Mac OS, even for
-# plain file/directory names.
-
-sub file_path_name {
- my $path = file_path(@_);
- $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
- return $path;
-}
+# Historically file_path_name differed on Mac OS classic.
+
+*file_path_name = \&file_path;
MkDir( dir_path('for_find'), 0770 );
touch( file_path('fb', 'fba', 'fba_ord') );
SKIP: {
skip "Creating symlink", 1, unless $symlink_exists;
-if ($^O eq 'MacOS') {
- ok( symlink(':fb',':fa:fsl'), 'Created symbolic link' );
-} else {
- ok( symlink('../fb','fa/fsl'), 'Created symbolic link' );
-}
+ ok( symlink('../fb','fa/fsl'), 'Created symbolic link' );
}
touch( file_path('fa', 'fa_ord') );