| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CopyTree::VendorProof::LocalFileOp; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
74699
|
use 5.008000; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
56
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#our @ISA = qw(CopyTree::VendorProof); #if this weren't commented out, the use base below won't work |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0013'; |
|
10
|
1
|
|
|
1
|
|
5
|
use Carp (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use File::Basename (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
17
|
|
|
12
|
1
|
|
|
1
|
|
936
|
use MIME::Base64 (); |
|
|
1
|
|
|
|
|
988
|
|
|
|
1
|
|
|
|
|
32
|
|
|
13
|
1
|
|
|
1
|
|
1300
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
10876
|
|
|
|
1
|
|
|
|
|
86
|
|
|
14
|
1
|
|
|
1
|
|
11
|
use base qw(CopyTree::VendorProof);#for the @ISAs |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1203
|
|
|
15
|
|
|
|
|
|
|
#use base happens at compile time, so we don't get the runtime error of our, saying that |
|
16
|
|
|
|
|
|
|
#Can't locate package CopyTree::VendorProof for @SharePoint::SOAPHandler::ISA at (eval 8) line 2. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
|
22
|
1
|
|
|
1
|
1
|
460
|
my $class =shift; |
|
23
|
1
|
|
|
|
|
3
|
my $path = shift; |
|
24
|
1
|
50
|
33
|
|
|
7
|
$path =~s/\/$// unless (!$path or $path eq '/'); |
|
25
|
1
|
|
|
|
|
2
|
my $hashref; |
|
26
|
1
|
|
|
|
|
5
|
$hashref = bless {path => $path}, $class; |
|
27
|
1
|
|
|
|
|
5
|
return $hashref; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#lists files and / or dirs of a dir |
|
31
|
|
|
|
|
|
|
sub fdls { |
|
32
|
7
|
|
|
7
|
1
|
119
|
my $inst = shift; |
|
33
|
|
|
|
|
|
|
|
|
34
|
7
|
50
|
|
|
|
24
|
unless (ref $inst ){ |
|
35
|
0
|
|
|
|
|
0
|
Carp::croak("fdls item must be an instance, not a class\n"); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
7
|
|
|
|
|
11
|
my $lsoption =shift; |
|
38
|
7
|
|
|
|
|
11
|
my $path =shift; |
|
39
|
7
|
50
|
33
|
|
|
53
|
$path =~s/\/$// unless (!$path or $path eq '/'); #removes trailing / |
|
40
|
|
|
|
|
|
|
|
|
41
|
7
|
50
|
|
|
|
22
|
$lsoption ='' if !($lsoption); |
|
42
|
7
|
50
|
|
|
|
16
|
$path = $inst ->SUPER::path if (!$path); |
|
43
|
7
|
|
|
|
|
8
|
my $dirH; |
|
44
|
7
|
50
|
|
|
|
235
|
opendir ($dirH, $path) or Carp::carp ("ERROR in local_ls cannot open dirH to $path $!\n"); |
|
45
|
7
|
|
|
|
|
270
|
my @itemsnoparent =readdir $dirH; |
|
46
|
7
|
|
|
|
|
97
|
closedir $dirH; |
|
47
|
7
|
|
|
|
|
9
|
my @results; |
|
48
|
|
|
|
|
|
|
my @files; |
|
49
|
0
|
|
|
|
|
0
|
my @dirs; |
|
50
|
7
|
|
|
|
|
14
|
for (@itemsnoparent){ |
|
51
|
74
|
100
|
100
|
|
|
318
|
next if ($_ eq '.' or $_ eq '..'); |
|
52
|
60
|
100
|
|
|
|
885
|
push @files, $path.'/'.$_ if (-f "$path/$_"); |
|
53
|
60
|
100
|
|
|
|
734
|
push @dirs, $path.'/'.$_ if (-d "$path/$_"); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
7
|
|
|
|
|
45
|
$inst ->SUPER::fdls_ret ($lsoption, \@files, \@dirs); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub is_fd{ |
|
59
|
26
|
|
|
26
|
1
|
6834
|
my $class_inst=shift; |
|
60
|
26
|
|
|
|
|
42
|
my $query = shift; |
|
61
|
26
|
100
|
|
|
|
550
|
if (-d $query){ |
|
|
|
100
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
23
|
return 'd'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
elsif (-f $query){ |
|
65
|
12
|
|
|
|
|
54
|
return 'f'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
else { |
|
68
|
8
|
|
|
|
|
326
|
my $parent = File::Basename::dirname($query); |
|
69
|
8
|
100
|
|
|
|
160
|
if (-d $parent){ |
|
|
1
|
|
|
|
|
5
|
|
|
70
|
7
|
|
|
|
|
35
|
return 'pd'; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
else{return 0} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
#memory is a ref to a scalar, in bin mode |
|
76
|
|
|
|
|
|
|
sub read_into_memory{ |
|
77
|
1
|
|
|
1
|
1
|
3
|
my $inst=shift; |
|
78
|
1
|
|
|
|
|
2
|
my $sourcepath = shift; |
|
79
|
1
|
50
|
|
|
|
7
|
$sourcepath =~s/\/$// unless $sourcepath eq '/'; |
|
80
|
1
|
50
|
|
|
|
4
|
$sourcepath=$inst->SUPER::path if (!$sourcepath); |
|
81
|
1
|
|
|
|
|
2
|
my $binfile; |
|
82
|
1
|
50
|
|
|
|
48
|
open my $readFH, "<", $sourcepath or Carp::carp("cannot read sourcepath [$sourcepath] $!\n"); |
|
83
|
1
|
|
|
|
|
3
|
binmode ($readFH); |
|
84
|
|
|
|
|
|
|
{#slurp |
|
85
|
1
|
|
|
|
|
2
|
local $/ =undef; |
|
|
1
|
|
|
|
|
7
|
|
|
86
|
1
|
|
|
|
|
31
|
$binfile = <$readFH>; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
1
|
|
|
|
|
12
|
close $readFH; |
|
89
|
1
|
|
|
|
|
6
|
return \$binfile; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
#memory is a ref to a scalar, in bin mode |
|
93
|
|
|
|
|
|
|
sub write_from_memory{ |
|
94
|
1
|
|
|
1
|
1
|
3
|
my $inst=shift; |
|
95
|
1
|
|
|
|
|
2
|
my $bincontentref = shift; |
|
96
|
1
|
|
|
|
|
3
|
my $dest = shift; |
|
97
|
1
|
50
|
|
|
|
4
|
$dest = $inst ->SUPER::path if (!$dest); |
|
98
|
1
|
50
|
|
|
|
130
|
open my $outFH, ">","$dest" or Carp::carp("cannot write to dest [$dest] $!\n"); |
|
99
|
1
|
|
|
|
|
4
|
binmode ($outFH); |
|
100
|
1
|
|
|
|
|
2
|
print $outFH $$bincontentref ; |
|
101
|
1
|
|
|
|
|
13
|
close $outFH; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub copy_local_files { |
|
107
|
6
|
|
|
6
|
1
|
110
|
my $inst = shift; |
|
108
|
6
|
|
|
|
|
11
|
my $source = shift; |
|
109
|
6
|
|
|
|
|
9
|
my $dest = shift; |
|
110
|
6
|
50
|
|
|
|
212
|
open my $inFH, "<", $source or Carp::carp( "cannot open source fh $source $!\n"); |
|
111
|
6
|
50
|
|
|
|
410
|
open my $ouFH, ">", $dest or Carp::carp( "cannot open dest fh $dest $!\n"); |
|
112
|
6
|
|
|
|
|
627
|
binmode ($inFH); |
|
113
|
6
|
|
|
|
|
8
|
binmode ($ouFH); |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
6
|
|
|
|
|
10
|
local $/=undef; #slurp |
|
|
6
|
|
|
|
|
23
|
|
|
116
|
6
|
|
|
|
|
125
|
my $content = <$inFH>; |
|
117
|
6
|
|
|
|
|
22
|
print $ouFH $content; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
6
|
|
|
|
|
60
|
close $inFH; |
|
120
|
6
|
|
|
|
|
79
|
close $ouFH; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub cust_mkdir{ |
|
124
|
4
|
|
|
4
|
1
|
2430
|
my $inst = shift; |
|
125
|
4
|
|
|
|
|
9
|
my $path = shift; |
|
126
|
4
|
100
|
|
|
|
171
|
Carp::croak( "should not be mkdiring a root [/]\n" )unless $path ne '/'; |
|
127
|
3
|
|
|
|
|
6
|
$path =~s/\/$// ; # purposefully disallow mkdir / unless $path eq '/'; |
|
128
|
3
|
50
|
|
|
|
252
|
mkdir $path or Carp::carp ("cannot mkdir $path $!\n"); |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
sub cust_rmdir{ |
|
132
|
4
|
|
|
4
|
1
|
1150
|
my $inst = shift; |
|
133
|
4
|
|
|
|
|
10
|
my $path = shift; |
|
134
|
4
|
100
|
|
|
|
337
|
Carp::croak( "should not be rmdiring a root [/]\n" )unless $path ne '/'; |
|
135
|
3
|
|
|
|
|
7
|
$path =~s/\/$// ; # purposefully disallow rmdir / unless $path eq '/'; |
|
136
|
3
|
50
|
|
|
|
124
|
unless (rmdir $path){ |
|
137
|
3
|
|
|
|
|
532
|
Carp::carp( "the dir [$path] you want to remove is NOT EMPTY $!\n"); |
|
138
|
3
|
100
|
|
|
|
501
|
Carp::croak( "wait. you told me to delete something that's not a dir. I'll stop for your protection.\n") if (! -d $path); |
|
139
|
2
|
|
|
|
|
13
|
my ($files, $dirs) = $inst ->ls_tree_fdret($path, $inst ->ls_tree($path) ); |
|
140
|
2
|
|
|
|
|
157
|
print Dumper $files; |
|
141
|
2
|
|
|
|
|
794
|
print Dumper $dirs; |
|
142
|
2
|
|
|
|
|
689
|
Carp::carp( "danger - going to take out the whole tree under [$path]\n"); |
|
143
|
2
|
|
|
|
|
402
|
Carp::carp( "going to wait 3 seconds. use Ctrl-c to escape this. Hold down the Ctrl key, and hit 'c'.\n"); |
|
144
|
2
|
|
|
|
|
6006935
|
sleep 3; |
|
145
|
2
|
|
|
|
|
60
|
for (@$files){ |
|
146
|
6
|
50
|
|
|
|
779
|
unlink $_ or Carp::carp ("cannot unlink $_ $!\n"); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
2
|
|
|
|
|
11
|
for (@$dirs){ |
|
149
|
1
|
50
|
|
|
|
467
|
rmdir $_ or Carp::carp ("cannot rmdir $_ $!\n"); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
2
|
|
|
|
|
286
|
rmdir $path; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
sub cust_rmfile { |
|
155
|
2
|
|
|
2
|
1
|
7
|
my $inst=shift; |
|
156
|
2
|
|
|
|
|
5
|
my $filepath=shift; |
|
157
|
2
|
50
|
|
|
|
54
|
Carp::croak("[$filepath] is not a file") if (! -f $filepath); |
|
158
|
2
|
|
|
|
|
377
|
unlink $filepath; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
|
164
|
|
|
|
|
|
|
__END__ |