| 1 | package Parse::Path::File::Win32; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $VERSION = '0.92'; # VERSION | |||||||||
| 4 | # ABSTRACT: C:\Windows\file\path\support | ||||||||||
| 5 | |||||||||||
| 6 | ############################################################################# | ||||||||||
| 7 | # Modules | ||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use sanity; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use Types::Standard qw(StrMatch); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | no warnings 'uninitialized'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | ############################################################################# | ||||||||||
| 18 | # Attributes | ||||||||||
| 19 | |||||||||||
| 20 | has volume => ( | ||||||||||
| 21 | is => 'rw', | ||||||||||
| 22 | isa => StrMatch[ qr/^[A-Za-z]?$/ ], | ||||||||||
| 23 | 22 | ▶ | default => sub { '' }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | ); | |||||||||
| 25 | |||||||||||
| 26 | ############################################################################# | ||||||||||
| 27 | # Required Methods | ||||||||||
| 28 | |||||||||||
| 29 | 2 | with 'Parse::Path::Role::Path'; | |||||||||
| 30 | |||||||||||
| 31 | 22 | ▶ | sub _build_blueprint { { | ||||||||
|
Subroutine
_build_blueprint: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 22 | hash_step_regexp => qr{ | |||||||||
| 33 | # Illegal characters: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx | ||||||||||
| 34 | (?<key>[^\x00-\x1F<>:"/\\|?*]*) | ||||||||||
| 35 | }x, | ||||||||||
| 36 | |||||||||||
| 37 | array_step_regexp => qr/\Z.\A/, # no-op; arrays not supported | ||||||||||
| 38 | delimiter_regexp => qr{\\+}, # + to capture repetitive slashes, like foo\\\\\bar | ||||||||||
| 39 | |||||||||||
| 40 | # no support for escapes | ||||||||||
| 41 | unescape_translation => [], | ||||||||||
| 42 | |||||||||||
| 43 | pos_translation => [ | ||||||||||
| 44 | [qr{^\\+$}, 0], | ||||||||||
| 45 | [qr{^\.\.\\*$}, 'X-1'], | ||||||||||
| 46 | [qr{^\.\\*$}, 'X-0'], | ||||||||||
| 47 | [qr{.?}, 'X+1'], | ||||||||||
| 48 | ], | ||||||||||
| 49 | |||||||||||
| 50 | delimiter_placement => { | ||||||||||
| 51 | '0R' => "\\", | ||||||||||
| 52 | HH => "\\", | ||||||||||
| 53 | }, | ||||||||||
| 54 | |||||||||||
| 55 | array_key_sprintf => '', | ||||||||||
| 56 | hash_key_stringification => [ | ||||||||||
| 57 | [qr/.?/, '%s'], | ||||||||||
| 58 | ], | ||||||||||
| 59 | } } | ||||||||||
| 60 | |||||||||||
| 61 | ############################################################################# | ||||||||||
| 62 | # Modified Methods | ||||||||||
| 63 | |||||||||||
| 64 | # Remove volume to the path | ||||||||||
| 65 | 22 | ▶ | around path_str2array => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 66 | 22 | my ($orig, $self, $path) = (shift, shift, shift); | |||||||||
| 67 | |||||||||||
| 68 | 22 | ▶ | $self->volume($1) if ($path =~ s/^([A-Za-z])\://); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | |||||||||||
| 70 | 22 | return $self->$orig($path, @_); | |||||||||
| 71 | 2 | }; | |||||||||
| 72 | |||||||||||
| 73 | # Uppercase volume on normalize | ||||||||||
| 74 | 15 | ▶ | around _normalize => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 15 | my ($orig, $self) = (shift, shift); | |||||||||
| 76 | |||||||||||
| 77 | 15 | $self->volume(uc $self->volume); | |||||||||
| 78 | |||||||||||
| 79 | 15 | return $self->$orig(@_); | |||||||||
| 80 | 2 | }; | |||||||||
| 81 | |||||||||||
| 82 | # Add volume to the path | ||||||||||
| 83 | 15 | ▶ | around as_string => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 84 | 15 | my ($orig, $self) = (shift, shift); | |||||||||
| 85 | |||||||||||
| 86 | 15 | my $path_str = $self->$orig(@_); | |||||||||
| 87 | 15 | my $V = $self->volume; | |||||||||
| 88 | |||||||||||
| 89 | 15 | ▶ | return ($V ? "$V:" : '').$path_str; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 2 | }; | |||||||||
| 91 | |||||||||||
| 92 | 2 | 42; | |||||||||
| 93 | |||||||||||
| 94 | __END__ | ||||||||||