Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[io grant] Amend rules for last part in IO::Path.resolve
Allow last part of path to not exist when using .resolve: :completely;
The resolution is still successful, and this lets us
.resolve(:completely) paths that we're about to create.
  • Loading branch information
zoffixznet committed Apr 16, 2017
1 parent 88140bb commit 51e4629
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/IO/Path.pm
Expand Up @@ -256,8 +256,12 @@ my class IO::Path is Cool does IO {

# Path part doesn't exist...
if !nqp::stat($next, nqp::const::STAT_EXISTS) {
# fail() if we were asked for complete resolution...
$completely and X::IO::Resolve.new(:path(self)).fail;
# fail() if we were asked for complete resolution and we still
# have further parts to resolve. If it's the last part,
# don't fail; it can be a yet-to-be-created file or dir
$completely
&& nqp::elems($parts)
&& X::IO::Resolve.new(:path(self)).fail;

# ...or handle rest in non-resolving mode if not
$resolved = $next;
Expand Down

0 comments on commit 51e4629

Please sign in to comment.