annotate Lib/Deployment/Batch/CopyFile.pm @ 32:56cef8e3cda6

+1
author Sergey
date Mon, 09 Nov 2009 01:39:31 +0300
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 package Deployment::Batch;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 our %Dirs;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 package Deployment::Batch::CopyFile;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 use base qw(Deployment::Batch::Generic);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 use File::Copy;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 require URI::file;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 DeclareProperty Src => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 DeclareProperty Dst => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 my ($this,$src,$dest,$Dir) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 $src or die "Source file name is required";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 $dest or die "Destination file name is reqiured";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 my $uriSrc = URI::file->new($src)->abs($this->Context->{PackageDir});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 my $uriDest = URI::file->new($dest);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 $uriDest = $uriDest->abs(
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 ($Dir and $Dirs{$Dir}) ?
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 $Dirs{$Dir} :
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 $this->Context->{PackageDir}
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 $this->{$Src} = $uriSrc->file;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 $this->{$Dst} = $uriDest->file;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 sub Run {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 $this->Log("Copy '$this->{$Src}' to '$this->{$Dst}'");
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 Deployment::Batch->Backup( File => $this->{$Dst} );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 copy($this->{$Src},$this->{$Dst}) or die "copy failed: $!";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45 1;