From: Bram Date: Mon, 12 May 2008 22:13:33 +0000 (+0200) Subject: Re: [perl #41555] Bug in File::Find on Windows when target X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68c65ec0adda9d2b3fc21f30f68be0ef10de5ad8;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #41555] Bug in File::Find on Windows when target Message-ID: <20080512221333.mq0283dlessws4wk@horde.wizbit.be> p4raw-id: //depot/perl@33911 --- diff --git a/lib/File/Find.pm b/lib/File/Find.pm index f316962..d39063b 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -795,7 +795,7 @@ sub _find_dir($$$) { if ($Is_MacOS) { $dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface } elsif ($^O eq 'MSWin32') { - $dir_pref = ($p_dir =~ m|\w:/$| ? $p_dir : "$p_dir/" ); + $dir_pref = ($p_dir =~ m|\w:/?$| ? $p_dir : "$p_dir/" ); } elsif ($^O eq 'VMS') { # VMS is returning trailing .dir on directories @@ -987,7 +987,7 @@ sub _find_dir($$$) { $dir_pref = "$dir_name:"; } elsif ($^O eq 'MSWin32') { - $dir_name = ($p_dir =~ m|\w:/$| ? "$p_dir$dir_rel" : "$p_dir/$dir_rel"); + $dir_name = ($p_dir =~ m|\w:/?$| ? "$p_dir$dir_rel" : "$p_dir/$dir_rel"); $dir_pref = "$dir_name/"; } elsif ($^O eq 'VMS') { diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t index 60834bd..6a71f98 100644 --- a/lib/File/Find/t/find.t +++ b/lib/File/Find/t/find.t @@ -18,8 +18,14 @@ BEGIN { $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; } } -if ( $symlink_exists ) { print "1..199\n"; } -else { print "1..85\n"; } +my $test_count = 85; +$test_count += 114 if $symlink_exists; +$test_count += 18 if $^O eq 'MSWin32'; +$test_count += 2 if $^O eq 'MSWin32' and $symlink_exists; + +print "1..$test_count\n"; +#if ( $symlink_exists ) { print "1..199\n"; } +#else { print "1..85\n"; } my $orig_dir = cwd(); @@ -830,3 +836,60 @@ if ( $symlink_exists ) { unlink file_path('fa', 'faa_sl'); } + + +# Win32 checks - [perl #41555] +if ($^O eq 'MSWin32') { + require File::Spec::Win32; + my ($volume) = File::Spec::Win32->splitpath($orig_dir, 1); + print STDERR "VOLUME = $volume\n"; + + # with chdir + %Expect_File = (File::Spec->curdir => 1, + file_path('fsl') => 1, + file_path('fa_ord') => 1, + file_path('fab') => 1, + file_path('fab_ord') => 1, + file_path('faba') => 1, + file_path('faba_ord') => 1, + file_path('faa') => 1, + file_path('faa_ord') => 1); + + delete $Expect_File{ file_path('fsl') } unless $symlink_exists; + %Expect_Name = (); + + %Expect_Dir = (dir_path('fa') => 1, + dir_path('faa') => 1, + dir_path('fab') => 1, + dir_path('faba') => 1, + dir_path('fb') => 1, + dir_path('fba') => 1); + + + + File::Find::find( {wanted => \&wanted_File_Dir}, topdir('fa')); + Check( scalar(keys %Expect_File) == 0 ); + + # no_chdir + %Expect_File = ($volume . file_path_name('fa') => 1, + $volume . file_path_name('fa', 'fsl') => 1, + $volume . file_path_name('fa', 'fa_ord') => 1, + $volume . file_path_name('fa', 'fab') => 1, + $volume . file_path_name('fa', 'fab', 'fab_ord') => 1, + $volume . file_path_name('fa', 'fab', 'faba') => 1, + $volume . file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1, + $volume . file_path_name('fa', 'faa') => 1, + $volume . file_path_name('fa', 'faa', 'faa_ord') => 1); + + + delete $Expect_File{ $volume . file_path_name('fa', 'fsl') } unless $symlink_exists; + %Expect_Name = (); + + %Expect_Dir = ($volume . dir_path('fa') => 1, + $volume . dir_path('fa', 'faa') => 1, + $volume . dir_path('fa', 'fab') => 1, + $volume . dir_path('fa', 'fab', 'faba') => 1); + + File::Find::find( {wanted => \&wanted_File_Dir, no_chdir => 1}, $volume . topdir('fa')); + Check( scalar(keys %Expect_File) == 0 ); +}