line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Repl::Spec::Type::FileType;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
389
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Parameters
|
8
|
|
|
|
|
|
|
# - isDir
|
9
|
|
|
|
|
|
|
# - isFile
|
10
|
|
|
|
|
|
|
# - isReadable
|
11
|
|
|
|
|
|
|
# - exists
|
12
|
|
|
|
|
|
|
sub new
|
13
|
|
|
|
|
|
|
{
|
14
|
1
|
|
|
1
|
0
|
2
|
my $invocant = shift;
|
15
|
1
|
|
33
|
|
|
5
|
my $class = ref($invocant) || $invocant;
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
7
|
my %params = (ISDIR=>0, ISFILE=>1, READABLE=>1, WRITEABLE=> 0, EXECUTABLE=>0, @_);
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
2
|
my $self = {};
|
20
|
1
|
|
|
|
|
2
|
$self->{ISDIR} = $params{ISDIR};
|
21
|
1
|
|
|
|
|
2
|
$self->{ISFILE} = $params{ISFILE};
|
22
|
1
|
|
|
|
|
2
|
$self->{READABLE} = $params{READABLE};
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
55
|
return bless $self, $class;
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub guard
|
28
|
|
|
|
|
|
|
{
|
29
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
30
|
0
|
|
|
|
|
|
my $arg = shift;
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $isdir = $self->{ISDIR};
|
33
|
0
|
|
|
|
|
|
my $isfile = $self->{ISFILE};
|
34
|
0
|
|
|
|
|
|
my $readable = $self->{READABLE};
|
35
|
0
|
|
|
|
|
|
my $writable = $self->{WRITABLE};
|
36
|
0
|
|
|
|
|
|
my $executable = $self->{EXECUTABLE};
|
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
croak sprintf("The file '%s' does not exist, it is not a file nor a directory.", $arg) if(! -e $arg);
|
39
|
0
|
0
|
0
|
|
|
|
croak sprintf("The file '%s' is a plain file and not a directory.", $arg) if($isdir && !(-d $arg));
|
40
|
0
|
0
|
0
|
|
|
|
croak sprintf("The file '%s' is a directory and not a plain file.") if($isfile && !(-f $arg));
|
41
|
0
|
0
|
0
|
|
|
|
croak sprintf("The file '%s' is not readable.", $arg) if($readable && !(-r $arg));
|
42
|
0
|
0
|
0
|
|
|
|
croak sprintf("The file '%s' is not writable.", $arg) if($writable && !(-w $arg));
|
43
|
0
|
0
|
0
|
|
|
|
croak sprintf("The file '%s' is not executable.", $arg) if($executable && !(-x $arg));
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return $arg;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub name
|
49
|
|
|
|
|
|
|
{
|
50
|
0
|
|
|
0
|
0
|
|
return 'file';
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1;
|