Mercurial > pub > Impl
comparison Lib/Deployment/Batch/CopyFile.pm @ 0:03e58a454b20
Создан репозитарий
| author | Sergey |
|---|---|
| date | Tue, 14 Jul 2009 12:54:37 +0400 |
| parents | |
| children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:03e58a454b20 |
|---|---|
| 1 use strict; | |
| 2 package Deployment::Batch; | |
| 3 our %Dirs; | |
| 4 package Deployment::Batch::CopyFile; | |
| 5 use base qw(Deployment::Batch::Generic); | |
| 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; |
