1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: backup_file.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $
10 UserTag backup-file Order file
11 UserTag backup-file AddAttr
12 UserTag backup-file Version $Revision: 1.5 $
13 UserTag backup-file Routine <<EOR
16 require File::Basename;
18 my ($file, $opt) = @_;
19 my $bu_file = "backup/$file";
20 $bu_file =~ s://+:/:g ;
21 $bu_file =~ m:(.*)/: ;
24 die ::errmsg("Cannot figure out backup directory from %s", $bu_file)
27 File::Path::mkpath($bu_dir)
28 or die ::errmsg("Cannot make backup directory %s: %s", $bu_dir, $!);
33 UI::Primitive::rotate($fn, { Directory => $bu_dir } )
34 or die ::errmsg("Cannot make backup of %s: %s", $bu_file, $!);
36 #::logDebug("ready to copy $file to $bu_file");
37 File::Copy::copy($file, $bu_file)
38 or die ::errmsg("Copy %s to %s: %s", $file, $bu_file, $!);
41 $::Scratch->{ui_error} = $@;
42 ::logError($::Scratch->{ui_error});