use DX::Lib::FS::Observation::PathStatus;
use DX::Lib::FS::Action::CreateDirectory;
use DX::Lib::FS::Action::CreateFile;
+use DX::Lib::FS::Action::SetPathMode;
use File::Spec;
use DX::SetOver;
use Moo;
[ react => [ qw(PS M) ], sub {
$_[0]->but(mode => $_[1]);
} ] ] ],
+ [ mode => [ qw(PS M) ],
+ [ exists_path => qw(PS) ],
+ [ not => [ info_prop => 'PS', \'mode', 'M' ] ],
+ [ act => [ qw(PS M) ], sub {
+ DX::Lib::FS::Action::SetPathMode->new(
+ path_status => $_[0], mode => $_[1]
+ )
+ } ] ],
);
sub load_into {
--- /dev/null
+package DX::Lib::FS::Action::SetPathMode;
+
+use Moo;
+
+has path_status => (is => 'ro', required => 1);
+has mode => (is => 'ro', required => 1);
+
+with 'DX::Role::Action';
+
+sub expected_effect {
+ my ($self) = @_;
+ my $ps = $self->path_status;
+ +(path_status => $ps->but(info => $ps->info->but(mode => $self->mode)));
+}
+
+sub _do_run {
+ my ($self) = @_;
+ chmod oct($self->mode), $self->path_status->path
+ or die "Failed to chmod ${\$self->path_status->path} to ${\$self->mode}: $!";
+ +(path_status => $self->path_status);
+}
+
+1;