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 authored Sep 20, 2023
1 parent d11b23e commit 0ab656e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Mojo/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ 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 0ab656e

Please sign in to comment.