Aion-Fs
view release on metacpan or search on metacpan
t/aion/fs.t view on Meta::CPAN
local $^O = "MacOS";
my $path = {
path => '::::mix:report.doc',
dir => "::::mix:",
folder => ":::mix",
file => "report.doc",
name => "report",
ext => "doc",
};
local ($::_g0 = do {path $path->{path}}, $::_e0 = do {$path}); ::is_deeply $::_g0, $::_e0, ' path $path->{path} # --> $path' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path $path}, $::_e0 = "$path->{path}"); ::ok $::_g0 eq $::_e0, ' path $path # => $path->{path}' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path 'report'}, $::_e0 = do {{path => 'report', file => 'report', name => 'report'}}); ::is_deeply $::_g0, $::_e0, ' path \'report\' # --> {path => \'report\', file => \'report\', name => \'report\'}' or ::diag ::_struct_diff($...
local ($::_g0 = do {path {volume => "x", file => "f"}}, $::_e0 = "x:f"); ::ok $::_g0 eq $::_e0, ' path {volume => "x", file => "f"} # => x:f' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path {folder => "x"}}, $::_e0 = "x:"); ::ok $::_g0 eq $::_e0, ' path {folder => "x"} # => x:' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
}
{
local $^O = "vmesa";
my $path = {
path => ' USERID FILE EXT VOLUME ',
userid => "USERID",
file => "FILE EXT",
name => "FILE",
ext => "EXT",
volume => "VOLUME",
};
local ($::_g0 = do {path $path->{path}}, $::_e0 = do {$path}); ::is_deeply $::_g0, $::_e0, ' path $path->{path} # --> $path' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path {volume => "x", file => "f"}}, $::_e0 = do {' f x'}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, ' path {volume => "x", file => "f"} # -> \' f x\'' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0...
}
#
# ### See also
#
# * https://en.wikipedia.org/wiki/Path_(computing)
#
# ÐодÑли Ð´Ð»Ñ Ð¾Ð¿ÑÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ ÐС, а знаÑÐ¸Ñ Ð¸ опÑеделениÑ, какие в ÐС ÑайловÑе пÑÑи:
#
# * `$^O` â ÑÑпеÑглобалÑÐ½Ð°Ñ Ð¿ÐµÑÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ñ Ð½Ð°Ð·Ð²Ð°Ð½Ð¸ÐµÐ¼ ÑекÑÑей ÐС.
# * [Devel::CheckOS](https://metacpan.org/pod/Devel::CheckOS), [Perl::OSType](https://metacpan.org/pod/Perl::OSType) â опÑеделÑÑÑ ÐС.
# * [Devel::AssertOS](https://metacpan.org/pod/Devel::AssertOS) â запÑеÑÐ°ÐµÑ Ð¸ÑполÑзоваÑÑ Ð¼Ð¾Ð´ÑÐ»Ñ Ð²Ð½Ðµ ÑказаннÑÑ
ÐС.
# * [System::Info](https://metacpan.org/pod/System::Info) â инÑоÑмаÑÐ¸Ñ Ð¾Ð± ÐС, ÐµÑ Ð²ÐµÑÑии, диÑÑÑибÑÑиве, CPU и Ñ
оÑÑе.
#
# ÐÑделÑÑÑ ÑаÑÑи ÑайловÑÑ
пÑÑей:
#
# * [File::Spec](https://metacpan.org/pod/File::Spec) â `($volume, $directories, $file) = File::Spec->splitpath($path)`. ÐоддеÑÐ¶Ð¸Ð²Ð°ÐµÑ ÑолÑко unix, win32, os/2, vms, cygwin и amigaos.
# * [File::Spec::Functions](https://metacpan.org/pod/File::Spec::Functions) â `($volume, $directories, $file) = splitpath($path)`.
# * [File::Spec::Mac](https://metacpan.org/pod/File::Spec::Mac) â вÑ
Ð¾Ð´Ð¸Ñ Ð² [File::Spec](https://metacpan.org/pod/File::Spec), но не опÑеделÑеÑÑÑ Ð¸Ð¼, поÑÑÐ¾Ð¼Ñ Ð¿ÑиÑ
одиÑÑÑ Ð¸ÑполÑзоваÑÑ Ð¾ÑделÑÐ...
# * [File::Basename](https://metacpan.org/pod/File::Basename) â `($name, $path, $suffix) = fileparse($fullname, @suffixlist)`.
# * [Path::Class::File](https://metacpan.org/pod/Path::Class::File) â `file('foo', 'bar.txt')->is_absolute`.
# * [Path::Extended::File](https://metacpan.org/pod/Path::Extended::File) â `Path::Extended::File->new($file)->basename`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->extname`.
# * [Path::Util](https://metacpan.org/pod/Path::Util) â `$filename = basename($dir)`.
# * [Parse::Path](https://metacpan.org/pod/Parse::Path) â `Parse::Path->new(path => 'gophers[0].food.count', style => 'DZIL')->push("chunk")`. РабоÑÐ°ÐµÑ Ñ Ð¿ÑÑÑми как Ñ Ð¼Ð°ÑÑивами (`push`, `pop`, `shift`, `splice`). Так ...
#
# ## transpath ($path?, $from, $to)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ÑоÑмаÑа одной ÐС в дÑÑгÑÑ.
#
# ÐÑли `$path` не Ñказан, Ñо иÑполÑзÑеÑÑÑ `$_`.
#
# ÐеÑеÑÐµÐ½Ñ Ð¿Ð¾Ð´Ð´ÐµÑживаемÑÑ
ÐС ÑмоÑÑиÑе в пÑимеÑаÑ
подпÑогÑÐ°Ð¼Ð¼Ñ `path` ÑÑÑÑ Ð²ÑÑе или Ñак: `keys %Aion::Fs::FS`.
#
# ÐÐ°Ð·Ð²Ð°Ð½Ð¸Ñ ÐС â ÑегиÑÑÑонезавиÑимÑ.
#
::done_testing; }; subtest 'transpath ($path?, $from, $to)' => sub {
local $_ = ">x>y>z.doc.zip";
local ($::_g0 = do {transpath "vos", "unix"}, $::_e0 = '/x/y/z.doc.zip'); ::ok $::_g0 eq $::_e0, 'transpath "vos", "unix" # \> /x/y/z.doc.zip' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {transpath "vos", "VMS"}, $::_e0 = '[.x.y]z.doc.zip'); ::ok $::_g0 eq $::_e0, 'transpath "vos", "VMS" # \> [.x.y]z.doc.zip' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {transpath $_, "vos", "RiscOS"}, $::_e0 = '.x.y.z/doc/zip'); ::ok $::_g0 eq $::_e0, 'transpath $_, "vos", "RiscOS" # \> .x.y.z/doc/zip' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
#
# ## splitdir (;$dir)
#
# Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð½Ð° ÑоÑÑавлÑÑÑие. ÐиÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{dir}`.
#
::done_testing; }; subtest 'splitdir (;$dir)' => sub {
local $^O = "unix";
local ($::_g0 = do {[ splitdir "/x/" ]}, $::_e0 = do {["", "x", ""]}); ::is_deeply $::_g0, $::_e0, '[ splitdir "/x/" ] # --> ["", "x", ""]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## joindir (;$dirparts)
#
# ÐбÑединÑÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð¸Ð· ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑеннÑÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{dir => $dir}`.
#
::done_testing; }; subtest 'joindir (;$dirparts)' => sub {
local $^O = "unix";
local ($::_g0 = do {joindir qw/x y z/}, $::_e0 = "x/y/z"); ::ok $::_g0 eq $::_e0, 'joindir qw/x y z/ # => x/y/z' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{ dir => joindir qw/x y z/ }}, $::_e0 = "x/y/z/"); ::ok $::_g0 eq $::_e0, 'path +{ dir => joindir qw/x y z/ } # => x/y/z/' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## splitext (;$ext)
#
# Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ ÑаÑÑиÑение на ÑоÑÑавлÑÑÑие. РаÑÑиÑение ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{ext}`.
#
::done_testing; }; subtest 'splitext (;$ext)' => sub {
local $^O = "unix";
local ($::_g0 = do {[ splitext ".x." ]}, $::_e0 = do {["", "x", ""]}); ::is_deeply $::_g0, $::_e0, '[ splitext ".x." ] # --> ["", "x", ""]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## joinext (;$extparts)
#
# ÐбÑединÑÐµÑ ÑаÑÑиÑение из ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑенное ÑаÑÑиÑение ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{ext => $ext}`.
#
::done_testing; }; subtest 'joinext (;$extparts)' => sub {
local $^O = "unix";
local ($::_g0 = do {joinext qw/x y z/}, $::_e0 = "x.y.z"); ::ok $::_g0 eq $::_e0, 'joinext qw/x y z/ # => x.y.z' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{ ext => joinext qw/x y z/ }}, $::_e0 = ".x.y.z"); ::ok $::_g0 eq $::_e0, 'path +{ ext => joinext qw/x y z/ } # => .x.y.z' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## include (;$pkg)
( run in 2.850 seconds using v1.01-cache-2.11-cpan-63c85eba8c4 )