Skip to content

Commit

Permalink
fix for handling changes in File::Find 1.41 on win
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mikemagowan committed Sep 22, 2023
1 parent d11b23e commit fff4b72
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Mojo/File.pm
Expand Up @@ -64,16 +64,17 @@ sub list_tree {
# The File::Find documentation lies, this is needed for CIFS
local $File::Find::dont_use_nlink = 1 if $options->{dont_use_nlink};

my $path = $^O eq 'MSWin32' ? $$self =~ s!\\!/!gr : $$self;
my %all;
my $wanted = sub {
if ($options->{max_depth}) {
(my $rel = $File::Find::name) =~ s!^\Q$$self\E/?!!;
(my $rel = $File::Find::name) =~ s!^\Q$path\E/?!!;
$File::Find::prune = 1 if splitdir($rel) >= $options->{max_depth};
}
$all{$File::Find::name}++ if $options->{dir} || !-d $File::Find::name;
};
find {wanted => $wanted, no_chdir => 1}, $$self if -d $$self;
delete $all{$$self};
find {wanted => $wanted, no_chdir => 1}, $path if -d $path;
delete $all{$path};

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

0 comments on commit fff4b72

Please sign in to comment.