Changeset 11179 for trunk/gsdl/perllib
- Timestamp:
- 2006-02-01T10:12:18+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/util.pm
r10281 r11179 246 246 } 247 247 248 # copies a directory and its contents, excluding subdirectories, into a new directory 249 sub cp_r_toplevel { 250 my $dest = pop (@_); 251 my (@srcfiles) = @_; 252 253 # a few sanity checks 254 if (scalar (@srcfiles) == 0) { 255 print STDERR "util::cp_r no destination directory given\n"; 256 return; 257 } elsif (-f $dest) { 258 print STDERR "util::cp_r destination must be a directory\n"; 259 return; 260 } 261 262 # create destination directory if it doesn't exist already 263 if (! -d $dest) { 264 my $store_umask = umask(0002); 265 mkdir ($dest, 0777); 266 umask($store_umask); 267 } 268 269 # copy the files 270 foreach my $file (@srcfiles) { 271 272 if (!-e $file) { 273 print STDERR "util::cp_r $file does not exist\n"; 274 275 } elsif (-d $file) { 276 # make the new directory 277 my ($filename) = $file =~ /([^\\\/]*)$/; 278 $dest = &util::filename_cat ($dest, $filename); 279 my $store_umask = umask(0002); 280 mkdir ($dest, 0777); 281 umask($store_umask); 282 283 # get the contents of this directory 284 if (!opendir (INDIR, $file)) { 285 print STDERR "util::cp_r could not open directory $file\n"; 286 } else { 287 my @filedir = readdir (INDIR); 288 closedir (INDIR); 289 foreach my $f (@filedir) { 290 next if $f =~ /^\.\.?$/; 291 292 # copy all the files in this directory, but not directories 293 my $ff = &util::filename_cat ($file, $f); 294 if (-f $ff) { 295 &cp($ff, $dest); 296 #&cp_r ($ff, $dest); 297 } 298 } 299 } 300 301 } else { 302 &cp($file, $dest); 303 } 304 } 305 } 248 306 249 307 sub mk_dir {
Note:
See TracChangeset
for help on using the changeset viewer.