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);
has mode => (is => 'ro', predicate => 1);
+has data => (is => 'ro', default => sub { '' });
+
sub expected_effect {
my ($self) = @_;
return +(path_status => PathStatus->new(
is_file => 1,
mode => ($self->has_mode ? $self->mode : '')
)
+ ), file_content => FileContent->new(
+ path => $self->path,
+ data => $self->data,
));
}
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));
}