10 |
|
|
11 |
sub mkpath { |
sub mkpath { |
12 |
my $file = shift; |
my $file = shift; |
13 |
my $dir = $1 if $file =~ s{^.+/[^/]+}{}; |
my $dir = $1 if $file =~ s{(^.+)/[^/]+}{$1}; |
14 |
File::Path::mkpath $dir unless -e $dir; |
if ( $dir && ! -d $dir ) { |
15 |
|
carp "# mkdir $dir"; |
16 |
|
File::Path::mkpath $dir; |
17 |
|
} |
18 |
} |
} |
19 |
|
|
20 |
sub append { |
sub append { |
74 |
|
|
75 |
sub copy_once { |
sub copy_once { |
76 |
my ( $from, $to ) = @_; |
my ( $from, $to ) = @_; |
77 |
$to ||= $from; |
die "no destination" unless $to; |
78 |
return if -e $to; |
return if -e $to; |
79 |
mkpath $to; |
mkpath $to; |
80 |
write_file $to, read_file $from; |
my $perm = (stat $from)[2]; |
81 |
# warn "# copy_once $to ", -s $to, " bytes"; |
carp "# copy_once $from => $to $perm"; |
82 |
|
write_file $to, read_file($from); |
83 |
|
chmod $perm, $to; |
84 |
} |
} |
85 |
|
|
86 |
1; |
1; |