Aion-Fs
view release on metacpan or search on metacpan
t/aion/fs.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
# # NAME
#
# Aion::Fs - ÑÑилиÑÑ Ð´Ð»Ñ Ñайловой ÑиÑÑемÑ: ÑÑение, запиÑÑ, поиÑк, замена Ñайлов и Ñ.д.
#
# # VERSION
#
# 0.2.2
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
use Aion::Fs;
lay mkpath "hello/world.txt", "hi!";
lay mkpath "hello/moon.txt", "noreplace";
lay mkpath "hello/big/world.txt", "hellow!";
lay mkpath "hello/small/world.txt", "noenter";
::like scalar do {mtime "hello";}, qr{^\d+(\.\d+)?$}, 'mtime "hello"; # ~> ^\d+(\.\d+)?$'; undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map cat, grep -f, find ["hello/big", "hello/small"]];}, $::_e0 = do {[qw/ hellow! noenter /]}); ::is_deeply $::_g0, $::_e0, '[map cat, grep -f, find ["hello/big", "hello/small"]]; # --> [qw/ hellow! noenter /]' or ::diag ::_stru...
my @noreplaced = replace { s/h/$a $b H/ }
find "hello", "-f", "*.txt", qr/\.txt$/, sub { /\.txt$/ },
noenter "*small*",
errorenter { warn "find $_: $!" };
local ($::_g0 = do {\@noreplaced;}, $::_e0 = do {["hello/moon.txt"]}); ::is_deeply $::_g0, $::_e0, '\@noreplaced; # --> ["hello/moon.txt"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {cat "hello/world.txt";}, $::_e0 = "hello/world.txt :utf8 Hi!"); ::ok $::_g0 eq $::_e0, 'cat "hello/world.txt"; # => hello/world.txt :utf8 Hi!' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {cat "hello/moon.txt";}, $::_e0 = "noreplace"); ::ok $::_g0 eq $::_e0, 'cat "hello/moon.txt"; # => noreplace' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {cat "hello/big/world.txt";}, $::_e0 = "hello/big/world.txt :utf8 Hellow!"); ::ok $::_g0 eq $::_e0, 'cat "hello/big/world.txt"; # => hello/big/world.txt :utf8 Hellow!' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef...
local ($::_g0 = do {cat "hello/small/world.txt";}, $::_e0 = "noenter"); ::ok $::_g0 eq $::_e0, 'cat "hello/small/world.txt"; # => noenter' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[find "hello", "*.txt"];}, $::_e0 = do {[qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/small/world.txt !]}); ::is_deeply $::_g0, $::_e0, '[find "hello", "*.txt"]; # --> [qw! hello/moon.txt hello/world.txt he...
my @dirs;
my $iter = find "hello", "-d";
while(<$iter>) {
push @dirs, $_;
}
local ($::_g0 = do {\@dirs;}, $::_e0 = do {[qw! hello hello/big hello/small !]}); ::is_deeply $::_g0, $::_e0, '\@dirs; # --> [qw! hello hello/big hello/small !]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
erase reverse find "hello";
local ($::_g0 = do {-e "hello";}, $::_e0 = do {undef}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '-e "hello"; # -> undef' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# # DESCRIPTION
#
# ÐÑÐ¾Ñ Ð¼Ð¾Ð´ÑÐ»Ñ Ð¾Ð±Ð»ÐµÐ³ÑÐ°ÐµÑ Ð¸ÑполÑзование Ñайловой ÑиÑÑемÑ.
#
# ÐодÑли `File::Path`, `File::Slurper` и
# `File::Find` обÑÐµÐ¼ÐµÐ½ÐµÐ½Ñ ÑазлиÑнÑми возможноÑÑÑми, коÑоÑÑе иÑполÑзÑÑÑÑÑ Ñедко, но ÑÑебÑÑÑ Ð²Ñемени на ознакомление и Ñем ÑамÑм повÑÑаÑÑ Ð¿Ð¾Ñог...
#
# Ð `Aion::Fs` же иÑполÑзован пÑинÑип пÑогÑаммиÑÐ¾Ð²Ð°Ð½Ð¸Ñ KISS - Ñем пÑоÑе, Ñем лÑÑÑе!
#
# СÑпеÑмодÑÐ»Ñ `IO::All` не ÑвлÑеÑÑÑ ÐºÐ¾Ð½ÐºÑÑенÑом `Aion::Fs`, Ñ.к. иÑполÑзÑÐµÑ ÐÐРподÑ
од, а `Aion::Fs` â ФÐ.
#
# * ÐÐÐ â обÑекÑно-оÑиенÑиÑованное пÑогÑаммиÑование.
# * ФРâ ÑÑнкÑионалÑное пÑогÑаммиÑование.
#
# # SUBROUTINES/METHODS
#
# ## cat ($file)
#
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'cat ($file)' => sub {
::like scalar do {cat "/etc/passwd"}, qr{root}, 'cat "/etc/passwd" # ~> root'; undef $::_g0; undef $::_e0;
#
# `cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
#
lay "unicode.txt", "â¯";
local ($::_g0 = do {length cat "unicode.txt"}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'length cat "unicode.txt" # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {length cat["unicode.txt", ":raw"]}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'length cat["unicode.txt", ":raw"] # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# `cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
#
::like scalar do {eval { cat "A" }; $@}, qr{cat A: No such file or directory}, 'eval { cat "A" }; $@ # ~> cat A: No such file or directory'; undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [autodie](https://metacpan.org/pod/autodie) â `open $f, "r.txt"; $s = join "", <$f>; close $f`.
# * [File::Slurp](https://metacpan.org/pod/File::Slurp) â `read_file('file.txt')`.
# * [File::Slurper](https://metacpan.org/pod/File::Slurper) â `read_text('file.txt')`, `read_binary('file.txt')`.
# * [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->load_file(file => 'file.txt')`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') > $contents`.
# * [IO::Util](https://metacpan.org/pod/IO::Util) â `$contents = ${ slurp 'file.txt' }`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->slurp`.
#
# ## lay ($file?, $content)
#
# ÐапиÑÑÐ²Ð°ÐµÑ `$content` в `$file`.
#
# * ÐÑли Ñказан один паÑамеÑÑ, иÑполÑзÑÐµÑ `$_` вмеÑÑо `$file`.
# * `lay`, иÑполÑзÑÐµÑ Ñлой `:utf8`. ÐÐ»Ñ ÑÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ð¸Ð½Ð¾Ð³Ð¾ ÑÐ»Ð¾Ñ Ð¸ÑполÑзÑеÑÑÑ Ð¼Ð°ÑÑив из двÑÑ
ÑлеменÑов в паÑамеÑÑе `$file`:
#
::done_testing; }; subtest 'lay ($file?, $content)' => sub {
local ($::_g0 = do {lay "unicode.txt", "â¯"}, $::_e0 = "unicode.txt"); ::ok $::_g0 eq $::_e0, 'lay "unicode.txt", "â¯" # => unicode.txt' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {lay ["unicode.txt", ":raw"], "â¯"}, $::_e0 = "unicode.txt"); ::ok $::_g0 eq $::_e0, 'lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
::like scalar do {eval { lay "/", "â¯" }; $@}, qr{lay /: Is a directory}, 'eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory'; undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [autodie](https://metacpan.org/pod/autodie) â `open $f, ">r.txt"; print $f $contents; close $f`.
# * [File::Slurp](https://metacpan.org/pod/File::Slurp) â `write_file('file.txt', $contents)`.
# * [File::Slurper](https://metacpan.org/pod/File::Slurper) â `write_text('file.txt', $contents)`, `write_binary('file.txt', $contents)`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') < $contents`.
# * [IO::Util](https://metacpan.org/pod/IO::Util) â `slurp \$contents, 'file.txt'`.
# * [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->write_file(file => 'file.txt', content => $contents, bitmask => 0644)`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->spew($chars, 'UTF-8')`.
#
# ## find (;$path, @filters)
#
# РекÑÑÑивно обÑ
Ð¾Ð´Ð¸Ñ Ð¸ возвÑаÑÐ°ÐµÑ Ð¿ÑÑи из Ñказанного пÑÑи или пÑÑей, еÑли `$path` ÑвлÑеÑÑÑ ÑÑÑлкой на маÑÑив. Ðез паÑамеÑÑов иÑполÑзÑÐµÑ `$_` кÐ...
#
# ФилÑÑÑÑ Ð¼Ð¾Ð³ÑÑ Ð±ÑÑÑ:
#
# * ÐодпÑогÑаммой â пÑÑÑ Ðº ÑекÑÑÐµÐ¼Ñ ÑÐ°Ð¹Ð»Ñ Ð¿ÐµÑедаÑÑÑÑ Ð² `$_`, а подпÑогÑамма должна веÑнÑÑÑ Ð¸ÑÑÐ¸Ð½Ñ Ð¸Ð»Ð¸ ложÑ, как они понимаÑÑÑÑ perl-ом.
# * Regexp â ÑеÑÑиÑÑÐµÑ ÐºÐ°Ð¶Ð´Ñй пÑÑÑ ÑегÑлÑÑнÑм вÑÑажением.
# * СÑÑока в виде "-Xxx", где `Xxx` â один или неÑколÑко Ñимволов. ÐналогиÑна опеÑаÑоÑам perl-а Ð´Ð»Ñ ÑеÑÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов. ÐÑимеÑ: `-fr` пÑовеÑÑÐµÑ Ð¿ÑÑÑ...
# * ÐÑÑалÑнÑе ÑÑÑоки пÑевÑаÑаÑÑÑÑ ÑÑнкÑией `wildcard` (Ñм. ниже) в ÑегÑлÑÑное вÑÑажение Ð´Ð»Ñ Ð¿ÑовеÑки каждого пÑÑи.
#
# ÐÑÑи, не пÑоÑедÑие пÑовеÑÐºÑ `@filters`, не возвÑаÑаÑÑÑÑ.
#
# ÐÑли ÑилÑÑÑ -X не ÑвлÑеÑÑÑ Ñайловой ÑÑнкÑией perl, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение:
#
::done_testing; }; subtest 'find (;$path, @filters)' => sub {
::like scalar do {eval { find "example", "-h" }; $@}, qr{Undefined subroutine &Aion::Fs::h called}, 'eval { find "example", "-h" }; $@ # ~> Undefined subroutine &Aion::Fs::h called'; undef $::_g0; undef $::_e0;
#
# Ð ÑÑом пÑимеÑе `find` не Ð¼Ð¾Ð¶ÐµÑ Ð²Ð¾Ð¹Ñи в подкаÑалог и пеÑедаÑÑ Ð¾ÑÐ¸Ð±ÐºÑ Ð² ÑÑнкÑÐ¸Ñ `errorenter` (Ñм. ниже) Ñ ÑÑÑановленнÑми пеÑеменнÑми `$_` и `$!` (пÑÑÑм к...
#
# **Ðнимание!** ÐÑли `errorenter` не Ñказана, Ñо вÑе оÑибки **игноÑиÑÑÑÑÑÑ**!
#
mkpath ["example/", 0];
local ($::_g0 = do {[find "example"]}, $::_e0 = do {["example"]}); ::is_deeply $::_g0, $::_e0, '[find "example"] # --> ["example"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[find "example", noenter "-d"]}, $::_e0 = do {["example"]}); ::is_deeply $::_g0, $::_e0, '[find "example", noenter "-d"] # --> ["example"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
::like scalar do {eval { find "example", errorenter { die "find $_: $!" } }; $@}, qr{find example: Permission denied}, 'eval { find "example", errorenter { die "find $_: $!" } }; $@ # ~> find example: Permission denied'; undef $::_g0; undef $::_e0;
mkpath for qw!ex/1/11 ex/1/12 ex/2/21 ex/2/22!;
my $count = 0;
find "ex", sub { find_stop if ++$count == 3; 1};
local ($::_g0 = do {$count}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '$count # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, ж...
# * [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { "$_" } grep { -f $_ && $_->size > 10*1024 } io(".")->all(0)`.
# * [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(">10k")->iter($dir1, $dir2); push @paths, "$f" while $f = $next->()`.
# * [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\.png/ }, $dir )`.
# * [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â как [File::Find](https://metacpan.org/pod/File::Find), ÑолÑко пÑÑи Ñайлов в _utf8_.
# * [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir...
# * [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.
# * [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии `imap` и `igrep`.
# * [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на `switch`.
# * [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: `tie @paths, IPC::Shareable, { key => "GLUE STRING", create => 1 };...
# * [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.
# * [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом.
# * [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â ÑÐ¼ÐµÐµÑ ÑÑавниваÑÑ Ð´Ð²Ð° каÑалога и возвÑаÑаÑÑ Ð¸Ñ
обÑединение, пеÑеÑеÑение и колиÑеÑÑвенное пеÑе...
# * [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â вÑбиÑÐ°ÐµÑ Ñайл или диÑекÑоÑÐ¸Ñ Ð½Ð°Ñгад из иеÑаÑÑ
ии Ñайлов.
# * [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.
# * [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. ÐÐ¼ÐµÐµÑ Ð¸ÑеÑаÑоÑ, пÑоÑе...
# * [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\.png/ }, $dir )`.
# * [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. РабоÑÐ°ÐµÑ Ð½Ð° `AnyEvent`. ÐаÑÑÑаиваемÑй. ÐÑÑÑ ÑаÑпаÑаллеливание на неÑк...
# * [File::Mirror](https://metacpan.org/pod/File::Mirror) â ÑоÑмиÑÑÐµÑ Ñак же паÑаллелÑнÑй пÑÑÑ Ð´Ð»Ñ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.
# * [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.
# * [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => "src///*.cpp", match => qr(^src/(.*?)\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @path...
# * [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` или `findbegin($dir); @paths = findall()`.
# * [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /)`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.
# * [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, "*.png" )`. ÐÐ»Ñ ÑложнÑÑ
запÑоÑов иÑполÑзÑÐµÑ _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $d...
# * [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.
# * [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(">10k")->all(@dirs); $i->size("<10k")...`.
# * [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, "$_" })`.
# * [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.
# * [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(">10k")->all($dir)`.
#
# ## noenter (@filters)
#
# ÐовоÑÐ¸Ñ `find` не вÑ
одиÑÑ Ð² каÑалоги ÑооÑвеÑÑÑвÑÑÑие ÑилÑÑÑам за ним.
#
# ## errorenter (&block)
#
# ÐÑзÑÐ²Ð°ÐµÑ `&block` Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð¹ оÑибки возникаÑÑей пÑи невозможноÑÑи войÑи в какой-либо каÑалог.
#
# ## find_stop ()
#
# ÐÑÑÐ°Ð½Ð°Ð²Ð»Ð¸Ð²Ð°ÐµÑ `find` бÑдÑÑи вÑзван в одном из его ÑилÑÑÑов, `errorenter` или `noenter`.
#
::done_testing; }; subtest 'find_stop ()' => sub {
my $count = 0;
find "ex", sub { find_stop if ++$count == 3; 1};
local ($::_g0 = do {$count}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '$count # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## erase (@paths)
#
# УдалÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¸ пÑÑÑÑе каÑалоги. ÐозвÑаÑÐ°ÐµÑ `@paths`. ÐÑи оÑибке ввода-вÑвода вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение.
#
::done_testing; }; subtest 'erase (@paths)' => sub {
::like scalar do {eval { erase "/" }; $@}, qr{erase dir /: Device or resource busy}, 'eval { erase "/" }; $@ # ~> erase dir /: Device or resource busy'; undef $::_g0; undef $::_e0;
::like scalar do {eval { erase "/dev/null" }; $@}, qr{erase file /dev/null: Permission denied}, 'eval { erase "/dev/null" }; $@ # ~> erase file /dev/null: Permission denied'; undef $::_g0; undef $::_e0;
#
# ### See also
#
# * `unlink` + `rmdir`.
# * [File::Path](https://metacpan.org/pod/File::Path) â `remove_tree("dir")`.
# * [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::rm($path)`. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->remove`.
#
# ## replace (&sub, @files)
#
# ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´Ñй Ñайл на `$_`, еÑли его изменÑÐµÑ `&sub`. ÐозвÑаÑÐ°ÐµÑ ÑайлÑ, в коÑоÑÑÑ
не бÑло замен.
#
# `@files` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
#
# `&sub` вÑзÑваеÑÑÑ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñайла из `@files`. Ð Ð½ÐµÑ Ð¿ÐµÑедаÑÑÑÑ:
#
# * `$_` â ÑодеÑжимое Ñайла.
# * `$a` â пÑÑÑ Ðº ÑайлÑ.
# * `$b` â Ñлой коÑоÑÑм бÑл ÑÑиÑан Ñайл и коÑоÑÑм он бÑÐ´ÐµÑ Ð·Ð°Ð¿Ð¸Ñан.
#
# РпÑимеÑе ниже Ñайл "replace.ex" ÑÑиÑÑваеÑÑÑ Ñлоем `:utf8`, а запиÑÑваеÑÑÑ Ñлоем `:raw` в ÑÑнкÑии `replace`:
#
::done_testing; }; subtest 'replace (&sub, @files)' => sub {
local $_ = "replace.ex";
lay "abc";
replace { $b = ":utf8"; y/a/¡/ } [$_, ":raw"];
local ($::_g0 = do {cat}, $::_e0 = "¡bc"); ::ok $::_g0 eq $::_e0, 'cat # => ¡bc' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [File::Edit](https://metacpan.org/pod/File::Edit) â `File::Edit->new($file)->replace('x', 'y')->save`.
# * [File::Edit::Portable](https://metacpan.org/pod/File::Edit::Portable) â `File::Edit::Portable->new->splice(file => $file, line => 10, contens => ["line1", "line2"])`.
# * [File::Replace](https://metacpan.org/pod/File::Replace) â `($infh,$outfh,$repl) = replace3($file); while (<$infh>) { print $outfh "X: $_" } $repl->finish`.
# * [File::Replace::Inplace](https://metacpan.org/pod/File::Replace::Inplace).
#
# ## mkpath (;$path)
#
# Ðак **mkdir -p**, но ÑÑиÑÐ°ÐµÑ Ð¿Ð¾ÑледнÑÑ ÑаÑÑÑ Ð¿ÑÑи (поÑле поÑледней коÑой ÑеÑÑÑ) именем Ñайла и не ÑоздаÑÑ ÐµÑ ÐºÐ°Ñалогом. Ðез паÑамеÑÑа иÑполÑзÑ...
#
# * ÐÑли `$path` не Ñказан, иÑполÑзÑÐµÑ `$_`.
# * ÐÑли `$path` ÑвлÑеÑÑÑ ÑÑÑлкой на маÑÑив, Ñогда иÑполÑзÑеÑÑÑ Ð¿ÑÑÑ Ð² каÑеÑÑве пеÑвого ÑлеменÑа и пÑава в каÑеÑÑве вÑоÑого ÑлеменÑа.
# * ÐÑава по ÑмолÑÐ°Ð½Ð¸Ñ â `0755`.
# * ÐозвÑаÑÐ°ÐµÑ `$path`.
#
( run in 1.578 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )