5c8346bcb4bfce9a7d4a35b2c1c5301048dd5667
[scpubgit/DKit.git] / lib / DX / Lib / FS / Action / CreateDirectory.pm
1 package DX::Lib::FS::Action::CreateDirectory;
2
3 use aliased 'DX::Lib::FS::Fact::PathStatus';
4 use aliased 'DX::Lib::FS::Fact::PathStatusInfo';
5 use DX::Lib::FS::Guts;
6 use Moo;
7
8 with 'DX::Role::Action';
9
10 has path => (is => 'ro', required => 1);
11
12 has mode => (is => 'ro', predicate => 1);
13
14 sub expected_effect {
15   my ($self) = @_;
16   return +(path_status => PathStatus->new(
17     path => $self->path,
18     info => PathStatusInfo->new(
19       is_directory => 1,
20       mode => ($self->has_mode ? $self->mode : '')
21     )
22   ));
23 }
24
25 sub _do_run {
26   my ($self) = @_;
27   DX::Lib::FS::Guts->create_directory($self->path, $self->mode);
28   +(path_status => $self->path);
29 }
30
31 1;