File: backout

package info (click to toggle)
html2ps 1.0b7-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,208 kB
  • sloc: perl: 4,539; tcl: 1,799; sh: 38; makefile: 4
file content (31 lines) | stat: -rwxr-xr-x 707 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl

use strict;
use File::Copy;
use File::Path;
use Cwd 'chdir';
use vars qw(%dest $odir $curr $file $dir);

%dest = ();
$0 =~ /(.*)backout$/i;
chdir $1 if $1;
$curr = $ENV{PWD};
open DAT, 'backout.dat' || die "Cannot open backout.dat\n";
chomp ($odir =<DAT>);
chdir $odir;
if($ENV{PWD} eq $curr) {die "Cannot chdir to backout directory $odir\n"};

while (($file, $dir) = split /\s+/, <DAT>) {
    unless(-r $file) {die "Cannot copy $file\n"};
    unless(-w $dir)  {die "$dir is not writable\n"};
    $dest{$file} = $dir;
}
close DAT;

while (($file, $dir) = each %dest) {
    copy $file => $dir or die "Cannot copy $file to $dir\n";
}

chdir $curr;
rmtree "$odir", 0, 0;
unlink 'backout.dat';