Changeset 37187 for main/trunk/greenstone2/perllib/FileUtils.pm
- Timestamp:
- 2023-01-27T23:52:38+13:00 (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/FileUtils.pm
r37151 r37187 120 120 # internal version that copies a file or a group of files 121 121 # 122 sub _copyFilesGeneral122 sub copyFilesGeneral 123 123 { 124 124 my ($srcfiles_ref,$dest,$options) = @_; … … 137 137 if (scalar(@$srcfiles_ref) == 0) 138 138 { 139 print STDERR "FileUtils:: _copyFilesGeneral() no destination directory given\n";139 print STDERR "FileUtils::copyFilesGeneral() no destination directory given\n"; 140 140 return 0; 141 141 } 142 142 elsif ((scalar(@$srcfiles_ref) > 1) && (!-d $dest)) 143 143 { 144 print STDERR "FileUtils:: _copyFilesGeneral() if multiple source files are given the destination must be a directory\n";144 print STDERR "FileUtils::copyFilesGeneral() if multiple source files are given the destination must be a directory\n"; 145 145 return 0; 146 146 } … … 159 159 if (!-e $file) 160 160 { 161 print STDERR "FileUtils:: _copyFilesGeneral() $file does not exist\n";161 print STDERR "FileUtils::copyFilesGeneral() $file does not exist\n"; 162 162 $had_an_error = 1; 163 163 if ($strict) { … … 167 167 elsif (!-f $file) 168 168 { 169 print STDERR "FileUtils:: _copyFilesGeneral() $file is not a regular file\n";169 print STDERR "FileUtils::copyFilesGeneral() $file is not a regular file\n"; 170 170 $had_an_error = 1; 171 171 if ($strict) { … … 181 181 if (!link($file, $tempdest)) 182 182 { 183 print STDERR "Warning: FileUtils:: _copyFilesGeneral(): unable to create hard link. ";183 print STDERR "Warning: FileUtils::copyFilesGeneral(): unable to create hard link. "; 184 184 print STDERR " Attempting file copy: $file -> $tempdest\n"; 185 185 $success = &File::Copy::copy($file, $tempdest); … … 195 195 196 196 if (!$success) { 197 print STDERR "FileUtils:: _copyFilesGeneral() failed to copy $file -> $tempdest\n";197 print STDERR "FileUtils::copyFilesGeneral() failed to copy $file -> $tempdest\n"; 198 198 $had_an_error = 1; 199 199 … … 226 226 my (@srcfiles) = @_; 227 227 228 return & _copyFilesGeneral(\@srcfiles,$dest,undef);228 return ©FilesGeneral(\@srcfiles,$dest,undef); 229 229 } 230 230 … … 306 306 my $strict = 0; 307 307 my $make_fullpath = 0; 308 my $exclude_dirs = 0; 309 my $exclude_files = 0; 308 310 my $exclude_filter_re = undef; 309 311 my $include_filter_re = undef; … … 312 314 $strict = $options->{'strict'} if defined $options->{'strict'}; 313 315 $make_fullpath = $options->{'make_fullpath'} if defined $options->{'make_fullpath'}; 316 $exclude_dirs = $options->{'exclude_dirs'} if defined $options->{'exclude_dirs'}; 317 $exclude_files = $options->{'exclude_files'} if defined $options->{'exclude_files'}; 314 318 $exclude_filter_re = $options->{'exclude_filter_re'} if defined $options->{'exclude_filter_re'}; 315 319 $include_filter_re = $options->{'include_filter_re'} if defined $options->{'include_filter_re'}; … … 330 334 { 331 335 next if $f_or_d =~ /^\.\.?$/; 336 next if $exclude_dirs && -d &filenameConcatenate($src_dir_fullpath, $f_or_d); 337 next if $exclude_files && -f &filenameConcatenate($src_dir_fullpath, $f_or_d); 332 338 next if (defined $exclude_filter_re && ($f_or_d =~ m/$exclude_filter_re/)); 333 339 … … 556 562 { 557 563 my $fullpath_subf = $fullpath_subf_or_subd; 558 my $ret_val_success = & _copyFilesGeneral([$fullpath_subf],$dest,$options);564 my $ret_val_success = ©FilesGeneral([$fullpath_subf],$dest,$options); 559 565 560 566 if ($ret_val_success == 0) { … … 585 591 else 586 592 { 587 my $ret_val_success = & _copyFilesGeneral([$file], $dest, $options);593 my $ret_val_success = ©FilesGeneral([$file], $dest, $options); 588 594 if ($ret_val_success == 0) { 589 595 … … 1487 1493 ## moveFiles() 1488 1494 1495 1496 ## @function renameDirectory() 1497 # 1498 # rename a directory 1499 # (effectively a move, where the destination name cannot already exist) 1500 # 1501 sub renameDirectory 1502 { 1503 my ($srcdir,$dstdir) = @_; 1504 1505 my $had_an_error = 0; 1506 1507 if (!-d $srcdir) { 1508 print STDERR "FileUtils::renameDirectory() Error - Source name must be an existing directory\n"; 1509 print STDERR "Source name was: $srcdir\n"; 1510 $had_an_error = 1; 1511 } 1512 elsif (-e $dstdir) { 1513 print STDERR "FileUtils::renameDirectory() Error - Destination name must not already exist\n"; 1514 print STDERR "Destination name was: $dstdir\n"; 1515 $had_an_error = 1; 1516 1517 } 1518 else { 1519 if (!rename($srcdir,$dstdir)) { 1520 print STDERR "FileUtils::renameDirectory() -- Error occured moving source name to destination name\n"; 1521 print STDERR "Source name was: $srcdir\n"; 1522 print STDERR "Destination name was: $dstdir\n"; 1523 $had_an_error = 1; 1524 } 1525 } 1526 1527 if ($had_an_error) { 1528 return 0; # i.e., not OK! 1529 } 1530 else { 1531 return 1; 1532 } 1533 } 1534 ## renameDirectory() 1535 1489 1536 ## @function openFileHandle() 1490 1537 #
Note:
See TracChangeset
for help on using the changeset viewer.