From 0ab656eacf941cfd3e0c23b54a1a8edec59b79d6 Mon Sep 17 00:00:00 2001 From: Mike Magowan Date: Wed, 20 Sep 2023 16:27:15 +0100 Subject: [PATCH] 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: https://github.com/Perl/perl5/commit/414f14df98cb1c9a20f92c5c54948b67c09f072d This then causes tests to fail in Mojo::File with Perl 5.38 on Windows. --- lib/Mojo/File.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Mojo/File.pm b/lib/Mojo/File.pm index 5bfc9343c2..d1525645d0 100644 --- a/lib/Mojo/File.pm +++ b/lib/Mojo/File.pm @@ -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); }