diff --git a/lib/Mojo/File.pm b/lib/Mojo/File.pm index b513f82efb..66ac829bb1 100644 --- a/lib/Mojo/File.pm +++ b/lib/Mojo/File.pm @@ -281,8 +281,10 @@ Include hidden files and directories. =head2 make_path $path = $path->make_path; + $path = $path->make_path({mode => 0711}); -Create the directories if they don't already exist with L. +Create the directories if they don't already exist with L. Any +additional arguments are passed through unmodified to L. =head2 move_to @@ -306,9 +308,11 @@ directory. =head2 remove_tree $path = $path->remove_tree; + $path = $path->remove_tree({keep_root => 1}); Delete this directory and any files and subdirectories it may contain with -L. +L. Any additional arguments are passed through unmodified to +L. =head2 slurp diff --git a/t/mojo/file.t b/t/mojo/file.t index 60d7b9c19a..c6c9b4534b 100644 --- a/t/mojo/file.t +++ b/t/mojo/file.t @@ -70,11 +70,18 @@ my $subdir = $dir->child('foo', 'bar'); ok !-d $subdir, 'directory does not exist anymore'; $subdir->make_path; ok -d $subdir, 'directory exists'; +my $nextdir = $dir->child('foo', 'foobar')->make_path({error => \my $error}); +ok -d $nextdir, 'directory exists'; +isa_ok $error, 'ARRAY', 'make_path modified variable'; # Remove tree $dir = tempdir; $dir->child('foo', 'bar')->make_path->child('test.txt')->spurt('test!'); is $dir->child('foo', 'bar', 'test.txt')->slurp, 'test!', 'right content'; +$subdir = $dir->child('foo', 'foobar')->make_path; +ok -e $subdir->child('bar')->make_path->child('a.out')->spurt('ELF'), 'created'; +ok -d $subdir->remove_tree({keep_root => 1}), 'arg passed through and dir kept'; +ok !-e $subdir->child('bar'), 'sub tree has been removed'; ok !-e $dir->child('foo')->remove_tree->to_string, 'tree has been removed'; # Move to