Mercurial > hg > foxridge-archiver
diff MPIWGStor.pm @ 10:4417be0e2f07
adapted to dsmc's problem with mount points
saves index.meta from overwriting by archived version
author | casties |
---|---|
date | Fri, 21 Jan 2005 15:33:26 +0100 |
parents | 30497c6a3eca |
children | 620aad237f57 |
line wrap: on
line diff
--- a/MPIWGStor.pm Tue Nov 30 13:39:51 2004 +0100 +++ b/MPIWGStor.pm Fri Jan 21 15:33:26 2005 +0100 @@ -13,14 +13,14 @@ $file_perm); use Exporter; -$VERSION = 0.3; # ROC 24.9.2003 +$VERSION = 0.4; # ROC 20.1.2005 @ISA = qw(Exporter); @EXPORT = qw($debug %junk_files %index_files $index_file_perm $archived_index_file_perm $file_perm &parseargs &logger &stime &s2stime &ymd_date &split_file_path &sstrip - &valid_file_name &valid_dir_name &read_xml &write_xml); + &valid_file_name &valid_dir_name &park_file &unpark_file &read_xml &write_xml); # debug level $debug = 0; @@ -211,6 +211,44 @@ # +# $newfilename = park_file($filename) +# +# parks a file under a new name (*.bak) +# +sub park_file { + my ($filename) = @_; + my $newfn = ""; + if (-f $filename) { + $newfn = "$filename.bak"; + if (! rename $filename, $newfn) { + logger("ABORT", "unable to rename file $filename!"); + exit 1; + } + } + return $newfn; +} + +# +# $filename = unpark_file($filename) +# +# unparks a file +# +sub unpark_file { + my ($filename) = @_; + my $newfn = "$filename.bak"; + if (-f $newfn) { + if (! rename $newfn, $filename) { + logger("ABORT", "unable to rename file $newfn!"); + exit 1; + } + return $filename; + } + return ""; +} + + + +# # ($document, $rootnode) = read_xml($file) # # reads xml meta file $file