+
+
+# 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 );
+}
+
+
+if ($symlink_exists) { # Issue 68260
+ print "# BUG 68260\n";
+ 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'));
+ }
+
+ use warnings;
+ my $dangling_symlink;
+ local $SIG {__WARN__} = sub {
+ local $" = " ";
+ $dangling_symlink ++ if "@_" =~ /dangling symbolic link/;
+ };
+
+ File::Find::find (
+ {
+ wanted => sub {1;},
+ follow => 1,
+ follow_skip => 2,
+ dangling_symlinks => 1,
+ },
+ File::Spec -> curdir
+ );
+
+ Check (!$dangling_symlink);
+}
+
+
+if ($^O eq 'MSWin32') {
+ # Check F:F:f correctly handles a root directory path.
+ # Rather than processing the entire drive (!), simply test that the
+ # first file passed to the wanted routine is correct and then bail out.
+ $orig_dir =~ /^(\w:)/ or die "expected a drive: $orig_dir";
+ my $drive = $1;
+
+ # Determine the file in the root directory which would be
+ # first if processed in sorted order. Create one if necessary.
+ my $expected_first_file;
+ opendir(ROOT_DIR, "/") or die "cannot opendir /: $!\n";
+ foreach my $f (sort readdir ROOT_DIR) {
+ if (-f "/$f") {
+ $expected_first_file = $f;
+ last;
+ }
+ }
+ closedir ROOT_DIR;
+ my $created_file;
+ unless (defined $expected_first_file) {
+ $expected_first_file = '__perl_File_Find_test.tmp';
+ open(F, ">", "/$expected_first_file") && close(F)
+ or die "cannot create file in root directory: $!\n";
+ $created_file = 1;
+ }
+
+ # Run F:F:f with/without no_chdir for each possible style of root path.
+ # NB. If HOME were "/", then an inadvertent chdir('') would fluke the
+ # expected result, so ensure it is something else:
+ local $ENV{HOME} = $orig_dir;
+ foreach my $no_chdir (0, 1) {
+ foreach my $root_dir ("/", "\\", "$drive/", "$drive\\") {
+ eval {
+ File::Find::find({
+ 'no_chdir' => $no_chdir,
+ 'preprocess' => sub { return sort @_ },
+ 'wanted' => sub {
+ -f or return; # the first call is for $root_dir itself.
+ my $got = $File::Find::name;
+ my $exp = "$root_dir$expected_first_file";
+ print "# no_chdir=$no_chdir $root_dir '$got'\n";
+ Check($got eq $exp);
+ die "done"; # don't process the entire drive!
+ },
+ }, $root_dir);
+ };
+ # If F:F:f did not die "done" then it did not Check() either.
+ unless ($@ and $@ =~ /done/) {
+ print "# no_chdir=$no_chdir $root_dir ",
+ ($@ ? "error: $@" : "no files found"), "\n";
+ Check(0);
+ }
+ }
+ }
+ if ($created_file) {
+ unlink("/$expected_first_file")
+ or warn "can't unlink /$expected_first_file: $!\n";
+ }
+}