X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FLib%2FFS%2FAction%2FCreateFile.pm;h=c05b3ef72c131ef7f1571e5f08c0576a6dcaaa91;hb=e02a5c0a6734a5f605c266c66bd696f7b6cfd65a;hp=426b241b4903e10935b219a7c0620b4e70bef817;hpb=a57a26e3c34837c2439b8a294da00ee66c93527b;p=scpubgit%2FDKit.git diff --git a/lib/DX/Lib/FS/Action/CreateFile.pm b/lib/DX/Lib/FS/Action/CreateFile.pm index 426b241..c05b3ef 100644 --- a/lib/DX/Lib/FS/Action/CreateFile.pm +++ b/lib/DX/Lib/FS/Action/CreateFile.pm @@ -1,5 +1,6 @@ package DX::Lib::FS::Action::CreateFile; +use aliased 'DX::Lib::FS::Fact::FileContent'; use aliased 'DX::Lib::FS::Fact::PathStatus'; use aliased 'DX::Lib::FS::Fact::PathStatusInfo'; use Fcntl qw(O_CREAT O_WRONLY); @@ -11,6 +12,8 @@ has path => (is => 'ro', required => 1); has mode => (is => 'ro', predicate => 1); +has data => (is => 'ro', default => sub { '' }); + sub expected_effect { my ($self) = @_; return +(path_status => PathStatus->new( @@ -19,6 +22,9 @@ sub expected_effect { is_file => 1, mode => ($self->has_mode ? $self->mode : '') ) + ), file_content => FileContent->new( + path => $self->path, + data => $self->data, )); } @@ -35,6 +41,7 @@ sub _do_run { sysopen($fh, $self->path, O_CREAT | O_WRONLY) or die "Couldn't create ${\$self->path}: $!"; } + print $fh $self->data if length($self->data); +(path_status => PathStatus->new(path => $self->path)); }