line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Path::File::Unix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.92'; # VERSION |
4
|
|
|
|
|
|
|
# ABSTRACT: /UNIX/file/path/support |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
############################################################################# |
7
|
|
|
|
|
|
|
# Modules |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
2082
|
use Moo; |
|
1
|
|
|
|
|
10947
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
2407
|
use sanity; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
428013
|
use namespace::clean; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
11
|
|
13
|
1
|
|
|
1
|
|
263
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
404
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
############################################################################# |
16
|
|
|
|
|
|
|
# Required Methods |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'Parse::Path::Role::Path'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _build_blueprint { { |
21
|
12
|
|
|
12
|
|
2669
|
hash_step_regexp => qr{ |
22
|
|
|
|
|
|
|
# Illegal characters are a mere \0 and / |
23
|
|
|
|
|
|
|
(?<key>[^/\0]*) |
24
|
|
|
|
|
|
|
}x, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
array_step_regexp => qr/\Z.\A/, # no-op; arrays not supported |
27
|
|
|
|
|
|
|
delimiter_regexp => qr{/+}, # + to capture repetitive slashes, like foo////bar |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# no support for escapes |
30
|
|
|
|
|
|
|
unescape_translation => [], |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
pos_translation => [ |
33
|
|
|
|
|
|
|
[qr{^/+$}, 0], |
34
|
|
|
|
|
|
|
[qr{^\.\./*$}, 'X-1'], |
35
|
|
|
|
|
|
|
[qr{^\./*$}, 'X-0'], |
36
|
|
|
|
|
|
|
[qr{.?}, 'X+1'], |
37
|
|
|
|
|
|
|
], |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
delimiter_placement => { |
40
|
|
|
|
|
|
|
'0R' => '/', |
41
|
|
|
|
|
|
|
HH => '/', |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
array_key_sprintf => '', |
45
|
|
|
|
|
|
|
hash_key_stringification => [ |
46
|
|
|
|
|
|
|
[qr/.?/, '%s'], |
47
|
|
|
|
|
|
|
], |
48
|
|
|
|
|
|
|
} } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
42; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding utf-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Parse::Path::File::Unix - /UNIX/file/path/support |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use v5.10; |
65
|
|
|
|
|
|
|
use Parse::Path; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $path = Parse::Path->new( |
68
|
|
|
|
|
|
|
path => '/root/.cpan', |
69
|
|
|
|
|
|
|
style => 'File::Unix', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
say $path->as_string; |
73
|
|
|
|
|
|
|
$path->push($path, 'FTPstats.yml'); |
74
|
|
|
|
|
|
|
say $path->as_string; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is a file-based path style for *nix paths. Some examples: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
/etc/foobar.conf |
81
|
|
|
|
|
|
|
/home/bbyrd/foo/bar.txt |
82
|
|
|
|
|
|
|
../..///.././aaa/.///bbb/ccc/../ddd |
83
|
|
|
|
|
|
|
foo/bar/../baz |
84
|
|
|
|
|
|
|
var/log/turnip.log |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Arrays are, of course, not supported. Neither is quoting, as that is a product of the shell, not the path itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Absolute paths will contain a blank first step, a la L<Path::Class>. Though, it is recommended to use |
89
|
|
|
|
|
|
|
L<is_absolute|Parse::Path/is_absolute> for checking for path relativity. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AVAILABILITY |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The project homepage is L<https://github.com/SineSwiper/Parse-Path/wiki>. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The latest version of this module is available from the Comprehensive Perl |
96
|
|
|
|
|
|
|
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN |
97
|
|
|
|
|
|
|
site near you, or see L<https://metacpan.org/module/Parse::Path/>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Brendan Byrd <bbyrd@cpan.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Brendan Byrd. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software, licensed under: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |