| 1 | package | ||||||||||||||||||||||||||||||||||||||||||
| 2 | Win32::Shortcut::Readlink; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw( carp ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use constant _is_cygwin => $^O eq 'cygwin'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use constant _is_mswin32 => $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use constant _is_windows => _is_cygwin || _is_mswin32; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | sub _real_readlink (_); | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # TODO: only warn in 5.14 or earlier if warnings on in caller | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | *_real_readlink = eval { require 5.016000 } ? \&CORE::readlink : sub (_) { CORE::readlink($_[0]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | sub readlink (_) | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readlink: called CC=7 SCAR=39.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | goto &_real_readlink unless _is_windows; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if(defined $_[0] && $_[0] =~ /\.lnk$/ && -r $_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_[0] and $_[0] =~ /\.lnk$/ and -r $_[0]
defined $_[0] and $_[0] =~ /\.lnk$/
MC/DC0%0/3
defined $_[0] and $_[0] =~ /\.lnk$/ and -r $_[0]
defined $_[0]
$_[0] =~ /\.lnk$/
-r $_[0]
Truth table0%0/4
A and B and C
A= defined $_[0]B= $_[0] =~ /\.lnk$/C= -r $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $target = _win32_resolve(_is_cygwin ? Cygwin::posix_to_win_path($_[0]) : $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return $target if defined $target; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | goto &_real_readlink if _is_cygwin; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # else is MSWin32 | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # emulate unix failues | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if(!defined $_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # TODO: only warn if warnings on in caller | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | carp "Use of uninitialized value in readlink"; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $! = 22; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | elsif(-e $_[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $! = 22; # Invalid argument | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | else | ||||||||||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $! = 2; # No such file or directory | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||||||||||||||||||||||||