Aion-Fs
view release on metacpan or search on metacpan
- fix pod
0.0.4 2023-11-15T09:21:57Z
- add see also in subroutines manual
- fix mkpath for working paths from root
- add subroutines: to_pkg and from_pkg
0.0.3 2023-10-19T15:34:24Z
- mtime in unixtime in subsecond resolution (from Time::HiRes::stat)
0.0.1 2023-10-07T00:33:36Z
- coverage 100%
0.01 2018-04-19T11:17:54Z
- original version
-d "A" # -> 1
```
### 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`). Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:
```perl
local $_ = "nofile";
eval { mtime }; $@ # ~> mtime nofile: No such file or directory
mtime ["/"] # ~> ^\d+(\.\d+)?$
```
### 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)
ÐозвÑаÑÐ°ÐµÑ ÑÑаÑиÑÑÐ¸ÐºÑ Ð¾ Ñайле. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
ЧÑÐ¾Ð±Ñ Ð¼Ð¾Ð¶Ð½Ð¾ бÑло иÑполÑзоваÑÑ Ñ Ð´ÑÑгими ÑайловÑми ÑÑнкÑиÑми, Ð¼Ð¾Ð¶ÐµÑ Ð¿Ð¾Ð»ÑÑаÑÑ ÑÑÑÐ»ÐºÑ Ð½Ð° маÑÑив из коÑоÑого беÑÑÑ Ð¿ÐµÑвÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð² каÑеÑÑв...
ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:
ÐодÑли Ð´Ð»Ñ Ð¾Ð¿ÑÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ ÐС, а знаÑÐ¸Ñ Ð¸ опÑеделениÑ, какие в ÐС ÑайловÑе пÑÑи:
* `$^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`.
ÐÐ°Ð·Ð²Ð°Ð½Ð¸Ñ ÐС â ÑегиÑÑÑонезавиÑимÑ.
```perl
local $_ = ">x>y>z.doc.zip";
transpath "vos", "unix" # \> /x/y/z.doc.zip
transpath "vos", "VMS" # \> [.x.y]z.doc.zip
transpath $_, "vos", "RiscOS" # \> .x.y.z/doc/zip
```
## splitdir (;$dir)
Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð½Ð° ÑоÑÑавлÑÑÑие. ÐиÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{dir}`.
```perl
local $^O = "unix";
[ splitdir "/x/" ] # --> ["", "x", ""]
```
## joindir (;$dirparts)
ÐбÑединÑÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð¸Ð· ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑеннÑÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{dir => $dir}`.
```perl
local $^O = "unix";
joindir qw/x y z/ # => x/y/z
path +{ dir => joindir qw/x y z/ } # => x/y/z/
```
## splitext (;$ext)
Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ ÑаÑÑиÑение на ÑоÑÑавлÑÑÑие. РаÑÑиÑение ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{ext}`.
```perl
local $^O = "unix";
[ splitext ".x." ] # --> ["", "x", ""]
```
## joinext (;$extparts)
ÐбÑединÑÐµÑ ÑаÑÑиÑение из ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑенное ÑаÑÑиÑение ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{ext => $ext}`.
```perl
local $^O = "unix";
joinext qw/x y z/ # => x.y.z
path +{ ext => joinext qw/x y z/ } # => .x.y.z
```
## include (;$pkg)
ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
Файл lib/A.pm:
i18n/Aion/Fs.ru-en.po view on Meta::CPAN
"* If `$path` is not specified, use `$_`.\n"
"* If `$path` is an array reference, then the path is used as the first element and rights as the second element.\n"
"* Default permissions are `0755`.\n"
"* Returns `$path`."
msgid "* [File::Path](https://metacpan.org/pod/File::Path) â `mkpath(\"dir1/dir2\")`.\n"
"* [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::mk($path)`. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений."
msgstr "* [File::Path](https://metacpan.org/pod/File::Path) â `mkpath(\"dir1/dir2\")`.\n"
"* [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::mk($path)`. Does not throw exceptions."
msgid "ÐÑÐµÐ¼Ñ Ð¼Ð¾Ð´Ð¸ÑикаÑии `$path` в unixtime Ñ Ð´Ñобной ÑаÑÑÑÑ (из `Time::HiRes::stat`). Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`."
msgstr "Modification time of `$path` in unixtime with fractional part (from `Time::HiRes::stat`). Without a parameter, uses `$_`."
msgid ""
"* `-M` â `-M \"file.txt\"`, `-M _` в днÑÑ
Ð¾Ñ ÑекÑÑего вÑемени.\n"
"* [stat](https://metacpan.org/pod/stat) â `(stat \"file.txt\")[9]` в ÑекÑндаÑ
(unixtime).\n"
"* [Time::HiRes](https://metacpan.org/pod/Time::HiRes) â `(Time::HiRes::stat \"file.txt\")[9]` в ÑекÑндаÑ
Ñ Ð´Ñобной ÑаÑÑÑÑ.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->stat->mtime`."
msgstr ""
"* `-M` â `-M \"file.txt\"`, `-M _` in days from the current time.\n"
"* [stat](https://metacpan.org/pod/stat) â `(stat \"file.txt\")[9]` in seconds (unixtime).\n"
"* [Time::HiRes](https://metacpan.org/pod/Time::HiRes) â `(Time::HiRes::stat \"file.txt\")[9]` in seconds with fractional part.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->stat->mtime`."
msgid "ÐозвÑаÑÐ°ÐµÑ ÑÑаÑиÑÑÐ¸ÐºÑ Ð¾ Ñайле. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`."
msgstr "Returns statistics about the file. Without a parameter, uses `$_`."
msgid "ЧÑÐ¾Ð±Ñ Ð¼Ð¾Ð¶Ð½Ð¾ бÑло иÑполÑзоваÑÑ Ñ Ð´ÑÑгими ÑайловÑми ÑÑнкÑиÑми, Ð¼Ð¾Ð¶ÐµÑ Ð¿Ð¾Ð»ÑÑаÑÑ ÑÑÑÐ»ÐºÑ Ð½Ð° маÑÑив из коÑоÑого беÑÑÑ Ð¿ÐµÑвÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð² каÑÐ...
msgstr "To be used with other file functions, it can receive a reference to an array from which it takes the first element as the file path."
msgid "ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:"
i18n/Aion/Fs.ru-en.po view on Meta::CPAN
msgstr ""
"* `$^O` â superglobal variable with the name of the current OS.\n"
"* [Devel::CheckOS](https://metacpan.org/pod/Devel::CheckOS), [Perl::OSType](https://metacpan.org/pod/Perl::OSType) â define the OS.\n"
"* [Devel::AssertOS](https://metacpan.org/pod/Devel::AssertOS) â prohibits the use of the module outside the specified OS.\n"
"* [System::Info](https://metacpan.org/pod/System::Info) â information about the OS, its version, distribution, CPU and host."
msgid "ÐÑделÑÑÑ ÑаÑÑи ÑайловÑÑ
пÑÑей:"
msgstr "Parts of file paths are distinguished:"
msgid ""
"* [File::Spec](https://metacpan.org/pod/File::Spec) â `($volume, $directories, $file) = File::Spec->splitpath($path)`. ÐоддеÑÐ¶Ð¸Ð²Ð°ÐµÑ ÑолÑко unix, win32, os/2, vms, cygwin и amigaos.\n"
"* [File::Spec::Functions](https://metacpan.org/pod/File::Spec::Functions) â `($volume, $directories, $file) = splitpath($path)`.\n"
"* [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)`.\n"
"* [Path::Class::File](https://metacpan.org/pod/Path::Class::File) â `file('foo', 'bar.txt')->is_absolute`.\n"
"* [Path::Extended::File](https://metacpan.org/pod/Path::Extended::File) â `Path::Extended::File->new($file)->basename`.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->extname`.\n"
"* [Path::Util](https://metacpan.org/pod/Path::Util) â `$filename = basename($dir)`.\n"
"* [Parse::Path](https://metacpan.org/pod/Parse::Path) â `Parse::Path->new(path => 'gophers[0].food.count', style => 'DZIL')->push(\"chunk\")`. РабоÑÐ°ÐµÑ Ñ Ð¿ÑÑÑми как Ñ Ð¼Ð°ÑÑивами (`push`, `pop`, `shift`, `splice`). Так...
msgstr ""
"* [File::Spec](https://metacpan.org/pod/File::Spec) â `($volume, $directories, $file) = File::Spec->splitpath($path)`. Only supports unix, win32, os/2, vms, cygwin and amigaos.\n"
"* [File::Spec::Functions](https://metacpan.org/pod/File::Spec::Functions) - `($volume, $directories, $file) = splitpath($path)`.\n"
"* [File::Spec::Mac](https://metacpan.org/pod/File::Spec::Mac) - included in [File::Spec](https://metacpan.org/pod/File::Spec), but not defined by it, so it has to be used separately. For mac os version 9.\n"
"* [File::Basename](https://metacpan.org/pod/File::Basename) â `($name, $path, $suffix) = fileparse($fullname, @suffixlist)`.\n"
"* [Path::Class::File](https://metacpan.org/pod/Path::Class::File) â `file('foo', 'bar.txt')->is_absolute`.\n"
"* [Path::Extended::File](https://metacpan.org/pod/Path::Extended::File) â `Path::Extended::File->new($file)->basename`.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->extname`.\n"
"* [Path::Util](https://metacpan.org/pod/Path::Util) - `$filename = basename($dir)`.\n"
"* [Parse::Path](https://metacpan.org/pod/Parse::Path) â `Parse::Path->new(path => 'gophers[0].food.count', style => 'DZIL')->push(\"chunk\")`. Works with paths as arrays (`push`, `pop`, `shift`, `splice`). It also overloads comparison operators. I...
msgid "ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ÑоÑмаÑа одной ÐС в дÑÑгÑÑ."
msgstr "Converts a path from one OS format to another."
msgid "ÐÑли `$path` не Ñказан, Ñо иÑполÑзÑеÑÑÑ `$_`."
msgstr "If `$path` is not specified, `$_` is used."
msgid "ÐеÑеÑÐµÐ½Ñ Ð¿Ð¾Ð´Ð´ÐµÑживаемÑÑ
ÐС ÑмоÑÑиÑе в пÑимеÑаÑ
подпÑогÑÐ°Ð¼Ð¼Ñ `path` ÑÑÑÑ Ð²ÑÑе или Ñак: `keys %Aion::Fs::FS`."
msgstr "For a list of supported operating systems, see the examples of the `path` subroutine just above or like this: `keys %Aion::Fs::FS`."
lib/Aion/Fs.md view on Meta::CPAN
-d "A" # -> 1
```
### 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`). Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:
```perl
local $_ = "nofile";
eval { mtime }; $@ # ~> mtime nofile: No such file or directory
mtime ["/"] # ~> ^\d+(\.\d+)?$
```
### 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)
ÐозвÑаÑÐ°ÐµÑ ÑÑаÑиÑÑÐ¸ÐºÑ Ð¾ Ñайле. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
ЧÑÐ¾Ð±Ñ Ð¼Ð¾Ð¶Ð½Ð¾ бÑло иÑполÑзоваÑÑ Ñ Ð´ÑÑгими ÑайловÑми ÑÑнкÑиÑми, Ð¼Ð¾Ð¶ÐµÑ Ð¿Ð¾Ð»ÑÑаÑÑ ÑÑÑÐ»ÐºÑ Ð½Ð° маÑÑив из коÑоÑого беÑÑÑ Ð¿ÐµÑвÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð² каÑеÑÑв...
ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:
lib/Aion/Fs.md view on Meta::CPAN
ÐодÑли Ð´Ð»Ñ Ð¾Ð¿ÑÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ ÐС, а знаÑÐ¸Ñ Ð¸ опÑеделениÑ, какие в ÐС ÑайловÑе пÑÑи:
* `$^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`.
ÐÐ°Ð·Ð²Ð°Ð½Ð¸Ñ ÐС â ÑегиÑÑÑонезавиÑимÑ.
```perl
local $_ = ">x>y>z.doc.zip";
transpath "vos", "unix" # \> /x/y/z.doc.zip
transpath "vos", "VMS" # \> [.x.y]z.doc.zip
transpath $_, "vos", "RiscOS" # \> .x.y.z/doc/zip
```
## splitdir (;$dir)
Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð½Ð° ÑоÑÑавлÑÑÑие. ÐиÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{dir}`.
```perl
local $^O = "unix";
[ splitdir "/x/" ] # --> ["", "x", ""]
```
## joindir (;$dirparts)
ÐбÑединÑÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð¸Ð· ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑеннÑÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{dir => $dir}`.
```perl
local $^O = "unix";
joindir qw/x y z/ # => x/y/z
path +{ dir => joindir qw/x y z/ } # => x/y/z/
```
## splitext (;$ext)
Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ ÑаÑÑиÑение на ÑоÑÑавлÑÑÑие. РаÑÑиÑение ÑледÑÐµÑ Ð²Ð½Ð°Ñале полÑÑиÑÑ Ð¸Ð· `path->{ext}`.
```perl
local $^O = "unix";
[ splitext ".x." ] # --> ["", "x", ""]
```
## joinext (;$extparts)
ÐбÑединÑÐµÑ ÑаÑÑиÑение из ÑоÑÑавлÑÑÑиÑ
. ÐаÑем полÑÑенное ÑаÑÑиÑение ÑледÑÐµÑ Ð²ÐºÐ»ÑÑиÑÑ Ð² `path +{ext => $ext}`.
```perl
local $^O = "unix";
joinext qw/x y z/ # => x.y.z
path +{ ext => joinext qw/x y z/ } # => .x.y.z
```
## include (;$pkg)
ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
Файл lib/A.pm:
lib/Aion/Fs.pm view on Meta::CPAN
use Aion::Fs::Find;
use Symbol qw//;
our @EXPORT = our @EXPORT_OK = grep {
ref \$Aion::Fs::{$_} eq "GLOB" && *{$Aion::Fs::{$_}}{CODE} && !/^(?:_|(NaN|import)\z)/
} keys %Aion::Fs::;
# СпиÑок ÐС Ñ ÑазлиÑаÑÑимÑÑ ÑинÑакÑиÑом ÑайловÑÑ
пÑÑей (должен бÑÑÑ Ð² нижнем ÑегиÑÑÑе)
use constant {
UNIX => 'unix',
AMIGAOS => 'amigaos',
CYGWIN => 'cygwin',
MSYS => 'msys',
MSYS2 => 'msys2',
MSWIN32 => 'mswin32',
DOS => 'dos',
OS2 => 'os2',
SYMBIAN => 'symbian',
VMS => 'vms',
VOS => 'vos',
lib/Aion/Fs.pm view on Meta::CPAN
my $x = substr $_->{regexp}, $pos, length($`) - $pos;
qr/()^$x\z/xsn
} if defined $group;
}
}
my $x = $_;
ref $_->{name}? (map { ($_ => $x) } @{$_->{name}}): ($_->{name} => $_)
} @FS;
sub _fs() { $FS{lc $^O} // $FS{unix} }
# ÐÑ Ð½Ð°Ñ
одимÑÑ Ð² ÐС ÑемейÑÑва UNIX
sub isUNIX() { _fs->{name} eq "unix" }
# Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð½Ð° ÑоÑÑавлÑÑÑие
sub splitdir(;$) {
my ($dir) = @_ == 0? $_: @_;
($dir) = @$dir if ref $dir;
my $fs = _fs;
$dir = $fs->{before_split}->($dir) if exists $fs->{before_split};
split $fs->{symdirquote}, $dir, -1
}
lib/Aion/Fs.pm view on Meta::CPAN
=over
=item * L<File::Path> â C<mkpath("dir1/dir2")>.
=item * L<File::Path::Tiny> â C<File::Path::Tiny::mk($path)>. Does not throw exceptions.
=back
=head2 mtime (;$path)
Modification time of C<$path> in unixtime with fractional part (from C<Time::HiRes::stat>). Without a parameter, uses C<$_>.
Throws an exception if the file does not exist or does not have permission:
local $_ = "nofile";
eval { mtime }; $@ # ~> mtime nofile: No such file or directory
mtime ["/"] # ~> ^\d+(\.\d+)?$
=head3 See also
=over
=item * C<-M> â C<-M "file.txt">, C<-M _> in days from the current time.
=item * L<stat> â C<(stat "file.txt")[9]> in seconds (unixtime).
=item * L<Time::HiRes> â C<(Time::HiRes::stat "file.txt")[9]> in seconds with fractional part.
=item * L<Mojo::File> â C<< path($file)-E<gt>stat-E<gt>mtime >>.
=back
=head2 sta (;$path)
Returns statistics about the file. Without a parameter, uses C<$_>.
lib/Aion/Fs.pm view on Meta::CPAN
=item * L<Devel::AssertOS> â prohibits the use of the module outside the specified OS.
=item * L<System::Info> â information about the OS, its version, distribution, CPU and host.
=back
Parts of file paths are distinguished:
=over
=item * L<File::Spec> â C<< ($volume, $directories, $file) = File::Spec-E<gt>splitpath($path) >>. Only supports unix, win32, os/2, vms, cygwin and amigaos.
=item * L<File::Spec::Functions> - C<($volume, $directories, $file) = splitpath($path)>.
=item * L<File::Spec::Mac> - included in L<File::Spec>, but not defined by it, so it has to be used separately. For mac os version 9.
=item * L<File::Basename> â C<($name, $path, $suffix) = fileparse($fullname, @suffixlist)>.
=item * L<Path::Class::File> â C<< file('foo', 'bar.txt')-E<gt>is_absolute >>.
=item * L<Path::Extended::File> â C<< Path::Extended::File-E<gt>new($file)-E<gt>basename >>.
=item * L<Mojo::File> â C<< path($file)-E<gt>extname >>.
=item * L<Path::Util> - C<$filename = basename($dir)>.
=item * L<Parse::Path> â C<< Parse::Path-E<gt>new(path =E<gt> 'gophers[0].food.count', style =E<gt> 'DZIL')-E<gt>push("chunk") >>. Works with paths as arrays (C<push>, C<pop>, C<shift>, C<splice>). It also overloads comparison operators. It has sty...
=back
=head2 transpath ($path?, $from, $to)
Converts a path from one OS format to another.
If C<$path> is not specified, C<$_> is used.
For a list of supported operating systems, see the examples of the C<path> subroutine just above or like this: C<keys %Aion::Fs::FS>.
OS names are case insensitive.
local $_ = ">x>y>z.doc.zip";
transpath "vos", "unix" # \> /x/y/z.doc.zip
transpath "vos", "VMS" # \> [.x.y]z.doc.zip
transpath $_, "vos", "RiscOS" # \> .x.y.z/doc/zip
=head2 splitdir (;$dir)
Splits a directory into components. The directory should first be obtained from C<< path-E<gt>{dir} >>.
local $^O = "unix";
[ splitdir "/x/" ] # --> ["", "x", ""]
=head2 joindir (;$dirparts)
Combines a directory from its components. The resulting directory should then be included in C<< path +{dir =E<gt> $dir} >>.
local $^O = "unix";
joindir qw/x y z/ # => x/y/z
path +{ dir => joindir qw/x y z/ } # => x/y/z/
=head2 splitext (;$ext)
Breaks the extension into its components. The extension should first be obtained from C<< path-E<gt>{ext} >>.
local $^O = "unix";
[ splitext ".x." ] # --> ["", "x", ""]
=head2 joinext (;$extparts)
Combines an extension from its components. The resulting extension should then be included in C<< path +{ext =E<gt> $ext} >>.
local $^O = "unix";
joinext qw/x y z/ # => x.y.z
path +{ ext => joinext qw/x y z/ } # => .x.y.z
=head2 include (;$pkg)
Connects C<$pkg> (if it has not already been connected via C<use> or C<require>) and returns it. Without a parameter, uses C<$_>.
lib/A.pm file:
t/aion/fs.t view on Meta::CPAN
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)
#
# ÐозвÑаÑÐ°ÐµÑ ÑÑаÑиÑÑÐ¸ÐºÑ Ð¾ Ñайле. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
# ЧÑÐ¾Ð±Ñ Ð¼Ð¾Ð¶Ð½Ð¾ бÑло иÑполÑзоваÑÑ Ñ Ð´ÑÑгими ÑайловÑми ÑÑнкÑиÑми, Ð¼Ð¾Ð¶ÐµÑ Ð¿Ð¾Ð»ÑÑаÑÑ ÑÑÑÐ»ÐºÑ Ð½Ð° маÑÑив из коÑоÑого беÑÑÑ Ð¿ÐµÑвÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð² каÑеÑÑ...
#
# ÐÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение, еÑли Ñайл не ÑÑÑеÑÑвÑÐµÑ Ð¸Ð»Ð¸ Ð½ÐµÑ Ð¿Ñав:
t/aion/fs.t view on Meta::CPAN
#
# ÐодÑли Ð´Ð»Ñ Ð¾Ð¿ÑÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ ÐС, а знаÑÐ¸Ñ Ð¸ опÑеделениÑ, какие в ÐС ÑайловÑе пÑÑи:
#
# * `$^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)
#
# ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
# Файл lib/A.pm:
( run in 0.584 second using v1.01-cache-2.11-cpan-df04353d9ac )