14 |
|
|
15 |
|
=cut |
16 |
|
|
17 |
< |
package AddDir; |
17 |
> |
package Utilities::AddDir; |
18 |
|
require 5.001; |
19 |
|
require Exporter; |
20 |
|
use Cwd; |
82 |
|
else |
83 |
|
{ |
84 |
|
copy($src."/".$file,$dest."/".$file); |
85 |
< |
if ( -x $src."/".$file || -X $src."/".$file ) {chmod(0775,$dest."/".$file);} |
85 |
> |
if ( -x $src."/".$file || -X $src."/".$file ) {chmod(0755,$dest."/".$file);} |
86 |
|
} |
87 |
|
} |
88 |
|
undef $dh; |
89 |
|
} |
90 |
|
else |
91 |
|
{ |
92 |
< |
die "Attempt to open a non-existent directory ($src). Exitting\n"; |
92 |
> |
die "Attempt to open a non-existent directory ($src). Exiting\n"; |
93 |
|
} |
94 |
|
} |
95 |
|
|
104 |
|
{ |
105 |
|
my $src=shift; |
106 |
|
my $dest=shift; |
107 |
< |
my ($filetoskip)=@_; |
107 |
> |
my $filetoskip=shift || []; |
108 |
|
|
109 |
|
use DirHandle; |
110 |
|
use File::Copy; |
122 |
|
{ |
123 |
|
next if $file=~/^\.\.?/; |
124 |
|
# Skip backup files and x~ files: |
125 |
< |
next if $file =~ /.*bak$/; |
125 |
> |
next if $file =~ /.*\.bak$/; |
126 |
|
next if $file =~ /.*~$/; |
127 |
|
|
128 |
< |
if ($file eq $filetoskip) |
128 |
> |
my $skip=0; |
129 |
> |
foreach my $fskip (@$filetoskip) |
130 |
> |
{ |
131 |
> |
my $fullfile = "${src}/${file}"; |
132 |
> |
if ($fullfile eq $fskip) |
133 |
> |
{ |
134 |
> |
$skip = 1; |
135 |
> |
last; |
136 |
> |
} |
137 |
> |
} |
138 |
> |
if ($skip) |
139 |
|
{ |
140 |
|
next; |
141 |
|
} |
142 |
|
|
143 |
|
if ( -d $src."/".$file ) |
144 |
|
{ |
145 |
< |
copydir($src."/".$file,$dest."/".$file); |
145 |
> |
copydirwithskip($src."/".$file,$dest."/".$file,$filetoskip); |
146 |
|
} |
147 |
|
else |
148 |
|
{ |
149 |
|
copy($src."/".$file,$dest."/".$file); |
150 |
< |
if ( -x $src."/".$file || -X $src."/".$file ) {chmod(0775,$dest."/".$file);} |
150 |
> |
if ( -x $src."/".$file || -X $src."/".$file ) {chmod(0755,$dest."/".$file);} |
151 |
|
} |
152 |
|
} |
153 |
|
undef $dh; |
154 |
|
} |
155 |
|
else |
156 |
|
{ |
157 |
< |
die "Attempt to open a non-existent directory ($src). Exitting\n"; |
157 |
> |
die "Attempt to open a non-existent directory ($src). Exiting\n"; |
158 |
|
} |
159 |
|
} |
160 |
|
|