Skip to content
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

Merged
merged 1 commit into from Dec 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Fixed resolve of IO::Path for Windows
Pathes with Windows volumes do no longer start with a seperator character.

IO::Path.resolve: Added $volume to CWD
  • Loading branch information
ufobat committed Nov 20, 2017
commit eed733e277528a46781ae4c82367d7691cb914c8
15 changes: 10 additions & 5 deletions src/core/IO/Path.pm
Expand Up @@ -238,13 +238,18 @@ my class IO::Path is Cool does IO {
my str $cur = $!SPEC.curdir;
my str $up = $!SPEC.updir;
my str $empty = '';
my str $resolved = $empty;
my Mu $res-list := nqp::list_s();

my %parts = $!SPEC.split: self.absolute;
my str $volume = %parts<volume>;
my str $resolved = $volume;
my $path = $!SPEC.catpath: '', |%parts<dirname basename>;

#?if jvm
# Apparently JVM doesn't know how to decode to utf8-c8 yet
# so it's still afflicted by the bug that, say, "/\[x308]" in the path
# doesn't get recognized as a path separator
my $parts := nqp::split($sep, nqp::unbox_s(self.absolute));
my $parts := nqp::split($sep, nqp::unbox_s($path));
#?endif
#?if !jvm
# In this bit, we work with bytes, converting $sep (and assuming it's
Expand All @@ -254,7 +259,7 @@ my class IO::Path is Cool does IO {
# part of the path part.
nqp::stmts(
(my $p := nqp::encode(
nqp::unbox_s(self.absolute), 'utf8-c8', buf8.new)),
nqp::unbox_s($path), 'utf8-c8', buf8.new)),
(my int $ord-sep = nqp::ord($sep)),
(my int $els = nqp::elems($p)),
(my int $i = -1),
Expand Down Expand Up @@ -323,8 +328,8 @@ my class IO::Path is Cool does IO {
nqp::push_s($res-list, $part);
}
}
$resolved = $sep unless nqp::chars($resolved);
IO::Path!new-from-absolute-path($resolved,:$!SPEC,:CWD($sep));
$resolved = $volume ~ $sep if $resolved eq $volume;
IO::Path!new-from-absolute-path($resolved,:$!SPEC,:CWD($volume ~ $sep));
}
proto method parent(|) {*}
multi method parent(IO::Path:D: UInt:D $depth) {
Expand Down