Skip to content

Commit

Permalink
specify :parent option in IO::Path.cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
labster committed Jun 27, 2013
1 parent 0af5ba1 commit 78487b0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions S32-setting-library/IO.pod
Original file line number Diff line number Diff line change
Expand Up @@ -583,17 +583,30 @@ without its full path.

=item cleanup

method cleanup( :$parent = False )

Returns a new IO::Path object with the canonical path. This eliminates extra
slashes and C<'.'> directories, but leaves C<'..'> in.
slashes and C<'.'> directories, but leaves C<'..'> in (or whatever the parent
directory is called on that platform).

With C<:parent>, cleanup will logically remove references to the parent
directory without I<checking the filesystem>. That is, the parent of a
symbolic link will remove the symlink itself, not the parent of the symlink's
destination.

=item resolve

Returns a new IO::Path object that has not only had C<cleanup> called, but also
removes symbolic links and references to the parent directory (C<..>).
Returns a new IO::Path object that is cleaned-up (as above), and all symbolic
links and references to the parent directory (C<..>) are physically resolved.
This means that the filesystem is examined for each directory in the path,
and any symlinks found are followed. Identical to C<.cleanup(:parent)> on systems
where symbolic links are not supported.

# bar is a symlink pointing to "/baz"
my $path = "foo/./bar///..".path;
$path.=cleanup; # now "foo/bar/.."
$path.=resolve; # now "foo" (if "bar" is not a symlink)
$path.cleanup(:parent); # yields "foo"
$path.=resolve; # now "/" (the parent of "/baz")

=item is-relative

Expand Down

0 comments on commit 78487b0

Please sign in to comment.