Skip to content

Commit

Permalink
Merge pull request #983 from perl6/rmdir-tree
Browse files Browse the repository at this point in the history
Rmdir tree
  • Loading branch information
awwaiid committed Oct 23, 2016
2 parents 0f370a6 + ae866ad commit 7889b3e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Type/IO/Path.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,20 @@ Returns C<True> on success. Throws an exception of type
L<X::IO::Rmdir> if the directory cannot be removed (e.g.
the directory is not empty, or the path is not a directory).
Since this only works on an empty directory, to remove a directory and its
contents you will have to do something more complex.
# When we have a directory first recurse, then remove it
multi sub rm-all(IO::Path $path where :d) {
$path.dir.map({ rm-all($^p) });
rmdir($path)
}
# Otherwise just remove the thing directly
multi sub rm-all(IO::Path $path) { $path.unlink }
See also L<rmtree in File::Directory::Tree|https://github.com/labster/p6-file-directory-tree>.
=head2 routine chmod
sub chmod($mode, *@filenames --> List)
Expand Down

0 comments on commit 7889b3e

Please sign in to comment.