Skip to content

Commit fff4b72

Browse files
committed
fix for handling changes in File::Find 1.41 on win
In a relatively recent update to File::Find (which was included in the Perl 5.38 release) a change was made to how the windows directory separator ('\') is handled and to convert this within File::Find to '/' to make it consistent: Perl/perl5@414f14d This then causes tests to fail in Mojo::File with Perl 5.38 on Windows.
1 parent d11b23e commit fff4b72

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Mojo/File.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ sub list_tree {
6464
# The File::Find documentation lies, this is needed for CIFS
6565
local $File::Find::dont_use_nlink = 1 if $options->{dont_use_nlink};
6666

67+
my $path = $^O eq 'MSWin32' ? $$self =~ s!\\!/!gr : $$self;
6768
my %all;
6869
my $wanted = sub {
6970
if ($options->{max_depth}) {
70-
(my $rel = $File::Find::name) =~ s!^\Q$$self\E/?!!;
71+
(my $rel = $File::Find::name) =~ s!^\Q$path\E/?!!;
7172
$File::Find::prune = 1 if splitdir($rel) >= $options->{max_depth};
7273
}
7374
$all{$File::Find::name}++ if $options->{dir} || !-d $File::Find::name;
7475
};
75-
find {wanted => $wanted, no_chdir => 1}, $$self if -d $$self;
76-
delete $all{$$self};
76+
find {wanted => $wanted, no_chdir => 1}, $path if -d $path;
77+
delete $all{$path};
7778

7879
return Mojo::Collection->new(map { $self->new(canonpath $_) } sort keys %all);
7980
}

0 commit comments

Comments
 (0)