49
|
1 use strict;
|
|
2 package Deployment::Batch;
|
|
3 our %Dirs;
|
|
4 package Deployment::Batch::CopyFile;
|
165
|
5 use parent qw(Deployment::Batch::Generic);
|
49
|
6 use File::Copy;
|
|
7 require URI::file;
|
|
8 use Common;
|
|
9
|
|
10 BEGIN {
|
|
11 DeclareProperty Src => ACCESS_READ;
|
|
12 DeclareProperty Dst => ACCESS_READ;
|
|
13 }
|
|
14
|
|
15 sub CTOR {
|
|
16 my ($this,$src,$dest,$Dir) = @_;
|
|
17
|
|
18 $src or die "Source file name is required";
|
|
19 $dest or die "Destination file name is reqiured";
|
|
20
|
|
21 my $uriSrc = URI::file->new($src)->abs($this->Context->{PackageDir});
|
|
22
|
|
23 my $uriDest = URI::file->new($dest);
|
|
24
|
|
25 $uriDest = $uriDest->abs(
|
|
26 ($Dir and $Dirs{$Dir}) ?
|
|
27 $Dirs{$Dir} :
|
|
28 $this->Context->{PackageDir}
|
|
29 );
|
|
30
|
|
31 $this->{$Src} = $uriSrc->file;
|
|
32 $this->{$Dst} = $uriDest->file;
|
|
33 }
|
|
34
|
|
35 sub Run {
|
|
36 my ($this) = @_;
|
|
37
|
|
38 $this->Log("Copy '$this->{$Src}' to '$this->{$Dst}'");
|
|
39
|
|
40 Deployment::Batch->Backup( File => $this->{$Dst} );
|
|
41
|
|
42 copy($this->{$Src},$this->{$Dst}) or die "copy failed: $!";
|
|
43 }
|
|
44
|
|
45 1;
|