Aion-Fs

 view release on metacpan or  search on metacpan

t/aion/fs.t  view on Meta::CPAN

local $_ = ["A", 0755];
local ($::_g0 = do {mkpath}, $::_e0 = "A"); ::ok $::_g0 eq $::_e0, 'mkpath   # => A' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

::like scalar do {eval { mkpath "/A/" }; $@}, qr{mkpath /A: Permission denied}, 'eval { mkpath "/A/" }; $@   # ~> mkpath /A: Permission denied'; undef $::_g0; undef $::_e0;

mkpath "A///./file";
local ($::_g0 = do {-d "A"}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '-d "A"  # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

# 
# ### See also
# 
# * [File::Path](https://metacpan.org/pod/File::Path) – `mkpath("dir1/dir2")`.
# * [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) – `File::Path::Tiny::mk($path)`. Не выбрасывает исключений.
# 
# ## mtime (;$path)
# 
# Время модификации `$path` в unixtime с дробной частью (из `Time::HiRes::stat`). Без параметра использует `$_`.
# 
# Выбрасывает исключение, если файл не существует или нет прав:
# 
::done_testing; }; subtest 'mtime (;$path)' => sub { 
local $_ = "nofile";
::like scalar do {eval { mtime }; $@}, qr{mtime nofile: No such file or directory}, 'eval { mtime }; $@  # ~> mtime nofile: No such file or directory'; undef $::_g0; undef $::_e0;

::like scalar do {mtime ["/"]}, qr{^\d+(\.\d+)?$}, 'mtime ["/"]   # ~> ^\d+(\.\d+)?$'; undef $::_g0; undef $::_e0;

# 
# ### See also
# 
# * `-M` – `-M "file.txt"`, `-M _` в днях от текущего времени.
# * [stat](https://metacpan.org/pod/stat) – `(stat "file.txt")[9]` в секундах (unixtime).
# * [Time::HiRes](https://metacpan.org/pod/Time::HiRes) – `(Time::HiRes::stat "file.txt")[9]` в секундах с дробной частью.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) – `path($file)->stat->mtime`.
# 
# ## sta (;$path)
# 
# Возвращает статистику о файле. Без параметра использует `$_`.
# 
# Чтобы можно было использовать с другими файловыми функциями, может получать ссылку на массив из которого берёт первый элемент в качест...
# 
# Выбрасывает исключение, если файл не существует или нет прав:
# 
::done_testing; }; subtest 'sta (;$path)' => sub { 
local $_ = "nofile";
::like scalar do {eval { sta }; $@}, qr{sta nofile: No such file or directory}, 'eval { sta }; $@  # ~> sta nofile: No such file or directory'; undef $::_g0; undef $::_e0;

::like scalar do {sta(["/"])->{ino}}, qr{^\d+$}, 'sta(["/"])->{ino} # ~> ^\d+$'; undef $::_g0; undef $::_e0;
::like scalar do {sta(".")->{atime}}, qr{^\d+(\.\d+)?$}, 'sta(".")->{atime} # ~> ^\d+(\.\d+)?$'; undef $::_g0; undef $::_e0;

# 
# ### See also
# 
# * [Fcntl](https://metacpan.org/pod/Fcntl) – содержит константы для распознавания режима.
# * [BSD::stat](https://metacpan.org/pod/BSD::stat) – дополнительно возвращает atime, ctime и mtime в наносекундах, флаги пользователя и номер генерации файла. Имеет ОÐ...
# * [File::chmod](https://metacpan.org/pod/File::chmod) – `chmod("o=,g-w","file1","file2")`, `@newmodes = getchmod("+x","file1","file2")`.
# * [File::stat](https://metacpan.org/pod/File::stat) – предоставляет ООП-интерфейс к stat.
# * [File::Stat::Bits](https://metacpan.org/pod/File::Stat::Bits) – аналогичен [Fcntl](https://metacpan.org/pod/Fcntl).
# * [File::stat::Extra](https://metacpan.org/pod/File::stat::Extra) – расширяет [File::stat](https://metacpan.org/pod/File::stat) методами для получения информации о режиме, а так же перезаÐ...
# * [File::Stat::Ls](https://metacpan.org/pod/File::Stat::Ls) – возвращает режим в формате утилиты ls.
# * [File::Stat::Moose](https://metacpan.org/pod/File::Stat::Moose) – ООП интерфейс на Moose.
# * [File::Stat::OO](https://metacpan.org/pod/File::Stat::OO) – предоставляет ООП-интерфейс к stat. Может возвращать atime, ctime и mtime сразу в `DateTime`.
# * [File::Stat::Trigger](https://metacpan.org/pod/File::Stat::Trigger) – следилка за изменением атрибутов файла.
# * [Linux::stat](https://metacpan.org/pod/Linux::stat) – парсит /proc/stat и возвращает доп-информацию. Однако в других ОС не работает.
# * [Stat::lsMode](https://metacpan.org/pod/Stat::lsMode) – возвращает режим в формате утилиты ls.
# * [VMS::Stat](https://metacpan.org/pod/VMS::Stat) – возвращает списки VMS ACL.
# 
# ## path (;$path)
# 
# Разбивает файловый путь на составляющие или собирает его из составляющих.
# 
# * Если получает ссылку на массив, то воспринимает его первый элемент как путь.
# * Если получает ссылку на хэш, то собирает из него путь. Незнакомые ключи просто игнорирует. Набор ключей для каждой ФС – разный.
# * ФС берётся из системной переменной `$^O`.
# * К файловой системе не обращается.
# 
::done_testing; }; subtest 'path (;$path)' => sub { 
{
    local $^O = "freebsd";

local ($::_g0 = do {path "."}, $::_e0 = do {{path => ".", file => ".", name => "."}}); ::is_deeply $::_g0, $::_e0, '    path "."        # --> {path => ".", file => ".", name => "."}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e...
local ($::_g0 = do {path ".bashrc"}, $::_e0 = do {{path => ".bashrc", file => ".bashrc", name => ".bashrc"}}); ::is_deeply $::_g0, $::_e0, '    path ".bashrc"  # --> {path => ".bashrc", file => ".bashrc", name => ".bashrc"}' or ::diag ::_struct_diff(...
local ($::_g0 = do {path ".bash.rc"}, $::_e0 = do {{path => ".bash.rc", file => ".bash.rc", name => ".bash", ext => "rc"}}); ::is_deeply $::_g0, $::_e0, '    path ".bash.rc"  # --> {path => ".bash.rc", file => ".bash.rc", name => ".bash", ext => "rc"...
local ($::_g0 = do {path ["/"]}, $::_e0 = do {{path => "/", dir => "/"}}); ::is_deeply $::_g0, $::_e0, '    path ["/"]      # --> {path => "/", dir => "/"}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
    local $_ = "";
local ($::_g0 = do {path}, $::_e0 = do {{path => ""}}); ::is_deeply $::_g0, $::_e0, '    path            # --> {path => ""}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path "a/b/c.ext.ly"}, $::_e0 = do {{path => "a/b/c.ext.ly", dir => "a/b", file => "c.ext.ly", name => "c", ext => "ext.ly"}}); ::is_deeply $::_g0, $::_e0, '    path "a/b/c.ext.ly"   # --> {path => "a/b/c.ext.ly", dir => "a/b", fil...

local ($::_g0 = do {path +{dir  => "/", ext => "ext.ly"}}, $::_e0 = "/.ext.ly"); ::ok $::_g0 eq $::_e0, '    path +{dir  => "/", ext => "ext.ly"}    # => /.ext.ly' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{file => "b.c", ext => "ly"}}, $::_e0 = "b.ly"); ::ok $::_g0 eq $::_e0, '    path +{file => "b.c", ext => "ly"}      # => b.ly' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{path => "a/b/f.c", dir => "m"}}, $::_e0 = "m/f.c"); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", dir => "m"}   # => m/f.c' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

    local $_ = +{path => "a/b/f.c", dir => undef, ext => undef};
local ($::_g0 = do {path}, $::_e0 = "f"); ::ok $::_g0 eq $::_e0, '    path # => f' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{path => "a/b/f.c", volume => "/x", dir => "m/y/", file => "f.y", name => "j", ext => "ext"}}, $::_e0 = "m/y//j.ext"); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", volume => "/x", dir => "m/y/", file => "f.y", name ...
local ($::_g0 = do {path +{path => "a/b/f.c", volume => "/x", dir => "/y", file => "f.y", name => "j", ext => "ext"}}, $::_e0 = "/y/j.ext"); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", volume => "/x", dir => "/y", file => "f.y", name => "j"...
}

{
    local $^O = "MSWin32"; # also os2, symbian and dos

local ($::_g0 = do {path "."}, $::_e0 = do {{path => ".", file => ".", name => "."}}); ::is_deeply $::_g0, $::_e0, '    path "."        # --> {path => ".", file => ".", name => "."}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e...
local ($::_g0 = do {path ".bashrc"}, $::_e0 = do {{path => ".bashrc", file => ".bashrc", name => ".bashrc"}}); ::is_deeply $::_g0, $::_e0, '    path ".bashrc"  # --> {path => ".bashrc", file => ".bashrc", name => ".bashrc"}' or ::diag ::_struct_diff(...
local ($::_g0 = do {path "/"}, $::_e0 = do {{path => "\\", dir => "\\", folder => "\\"}}); ::is_deeply $::_g0, $::_e0, '    path "/"        # --> {path => "\\", dir => "\\", folder => "\\"}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; und...
local ($::_g0 = do {path "\\"}, $::_e0 = do {{path => "\\", dir => "\\", folder => "\\"}}); ::is_deeply $::_g0, $::_e0, '    path "\\"       # --> {path => "\\", dir => "\\", folder => "\\"}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; un...
local ($::_g0 = do {path ""}, $::_e0 = do {{path => ""}}); ::is_deeply $::_g0, $::_e0, '    path ""         # --> {path => ""}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path "a\\b\\c.ext.ly"}, $::_e0 = do {{path => "a\\b\\c.ext.ly", dir => "a\\b\\", folder => "a\\b", file => "c.ext.ly", name => "c", ext => "ext.ly"}}); ::is_deeply $::_g0, $::_e0, '    path "a\\b\\c.ext.ly"   # --> {path => "a\\b\...

local ($::_g0 = do {path +{dir  => "/", ext => "ext.ly"}}, $::_e0 = "\\.ext.ly"); ::ok $::_g0 eq $::_e0, '    path +{dir  => "/", ext => "ext.ly"}    # => \\.ext.ly' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{dir  => "\\", ext => "ext.ly"}}, $::_e0 = "\\.ext.ly"); ::ok $::_g0 eq $::_e0, '    path +{dir  => "\\", ext => "ext.ly"}   # => \\.ext.ly' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{file => "b.c", ext => "ly"}}, $::_e0 = "b.ly"); ::ok $::_g0 eq $::_e0, '    path +{file => "b.c", ext => "ly"}      # => b.ly' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{path => "a/b/f.c", dir => "m/r/"}}, $::_e0 = "m\\r\\f.c"); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", dir => "m/r/"}   # => m\\r\\f.c' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

local ($::_g0 = do {path +{path => "a/b/f.c", dir => undef, ext => undef}}, $::_e0 = "f"); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", dir => undef, ext => undef} # => f' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {path +{path => "a/b/f.c", volume => "x", dir => "m/y/", file => "f.y", name => "j", ext => "ext"}}, $::_e0 = 'x:m\y\j.ext'); ::ok $::_g0 eq $::_e0, '    path +{path => "a/b/f.c", volume => "x", dir => "m/y/", file => "f.y", name =...
local ($::_g0 = do {path +{path => "x:/a/b/f.c", volume => undef, dir =>  "/y/", file => "f.y", name => "j", ext => "ext"}}, $::_e0 = '\y\j.ext'); ::ok $::_g0 eq $::_e0, '    path +{path => "x:/a/b/f.c", volume => undef, dir =>  "/y/", file => "f.y",...
}

{
    local $^O = "amigaos";

    my $path = {



( run in 0.858 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )