New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC && 3rd attempt: Fixed resolve of IO::Path for Windows #1249
Conversation
59d5c08
to
b059e66
Compare
|
|
What about the CWD attribute of the resultant path? Currently it's being set with this at the end of IO::Path!new-from-absolute-path($resolved,:$!SPEC,:CWD($sep));So it'd end up as just a separator; can't tell off hand if that's going to cause issues down the road, but, say, It's possible the fix can simply be concatenating the |
|
Sorry to see you make so many revisions, but I'm seeing three extra problems with this version. My code suggestions below are mere guesses and were not tested. 1) Only absolute paths get resolved right C:\rakudo-git>perl6 -e "IO::Path.new('C:\rakudo-git').resolve.say"
"C:\rakudo-git".IO
C:\rakudo-git>perl6 -e "IO::Path.new('.').resolve.say"
"\C:\rakudo-git".IOThis part will only set the volume for absolute paths: my str $volume = %.parts<volume>;
my $path = join $sep, %!parts<dirname basename>;
$path = $.is-absolute ?? $path !! join $sep, ($.CWD, $path);For relative paths, it'll fallback to the old problematic method of having the volume in the path. Instead, you should absolutify the path first (also, I now realized my suggestion to just my %parts := $!SPEC.split: self.absolute;
my $path := $!SPEC.catpath: '', |%parts<dirname basename>;The volume is then accessible in 2) Paths with volumes that differ from current volume get resolved on the wrong volume. This example shows the file exists when we print the size, but resolving that path fails: C:\rakudo-git>perl6 -e "with IO::Path.new('X:\bug\bug3.jpg') { .s.say; .resolve( :completely).say }"
46252
Failed to completely resolve IO::Path.new("X:\\bug\\bug3.jpg", :SPEC(IO::Spec::Win32), CWD("C:\\rakudo-git"))
in block <unit> at -e line 1The code merely extracts the volume from the path and re-attaches it at the end. I think this can be fixed by moving $resolved = $sep unless nqp::chars($resolved);
$resolved = $volume ~ $resolved;Untested, but probably just need to remove the second line and change the first one to: $resolved = $volume ~ $sep if $resolved eq $volume;3) Slash after volume gets messed up C:\rakudo-git>perl6 -e "IO::Path.new('C:\rakudo-git\nqp').resolve.say"
"C:\rakudo-git\nqp".IO
C:\rakudo-git>perl6 -e "IO::Path.new('C:/rakudo-git/nqp').resolve.say"
"C:\/rakudo-git\nqp".IOThe second version added an extraneous slash after the volume. I believe it's because of this line: It needs something more sophisticated, but the solution to |
|
shoudn't we have all this in the spec tests as well? |
Yes, we should :) |
Pathes with Windows volumes do no longer start with a seperator character. IO::Path.resolve: Added $volume to CWD
|
what should be the result of "C:foo" with $*SPEC = IO::Spec::Win32 on linux? I find it strange/wrong that "C:foo".absolute killes the volume. But this would be a bug in .absolute()? |
Makes sense to me. It's a relative path and your It has similar behaviour on Windows. Is it a bug? No idea, but the gut feeling is "no, it isn't": |
|
https://en.wikipedia.org/wiki/Path_(computing)#MS-DOS.2FMicrosoft_Windows_style
file: uri rfc also has some notes on this (ignore the leading
|
|
is there something missing or could this be merged? |
|
👍 Thanks! |
Pathes with Windows volumes do no longer start with a seperator character.