X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FLib%2FFS.pm;fp=lib%2FDX%2FLib%2FFS.pm;h=0e2b51b518aa6690306be4711906717cd39e76a6;hb=6a7c71ffb2075a9349e22e39fb19abdaad7e84e7;hp=4b391add27bf180e373d0fef130982aabf660c28;hpb=7ca660cb75c4248a653dd68036227e309faaac9b;p=scpubgit%2FDKit.git diff --git a/lib/DX/Lib/FS.pm b/lib/DX/Lib/FS.pm index 4b391ad..0e2b51b 100644 --- a/lib/DX/Lib/FS.pm +++ b/lib/DX/Lib/FS.pm @@ -1,6 +1,7 @@ package DX::Lib::FS; use DX::Lib::FS::Observation::PathStatus; +use DX::Lib::FS::Observation::EnvDir; use DX::Lib::FS::Action::CreateDirectory; use DX::Lib::FS::Action::CreateFile; use DX::Lib::FS::Action::SetPathMode; @@ -186,12 +187,43 @@ our @RULES = ( [ catfile => qw(DirPath FileName FilePath) ], [ is_directory => 'DirPath' ], [ is_file => 'FilePath' ] ], + + [ directory_in => [ qw(DirPath DirName SubdirPath) ], + [ catfile => qw(DirPath DirName SubdirPath) ], + [ is_directory => 'DirPath' ], + [ is_directory => 'SubdirPath' ] ], + + [ env_dir => [ qw(ED) ], + [ member_of => 'ED', \'env_dir' ] ], + + [ _env_dir_at => [ qw(ED P) ], + [ env_dir => 'ED' ], + [ prop => ED => \'path' => 'P' ] ], + + [ env_dir_at => [ qw(ED P) ], + [ _env_dir_at => qw(ED P) ], + [ 'cut' ] ], + + [ env_dir_at => [ 'ED', 'P' ], + [ observe => [ 'P' ], sub { + DX::Lib::FS::Observation::EnvDir->new( + path => $_[0] + ) + } ], + [ _env_dir_at => qw(ED P) ] ], + + [ home_dir_on => [ qw(A D) ], + [ path_on => 'A', \'HOME', 'P' ], + [ env_dir_at => ED => 'P' ], + [ prop => ED => \'value' => 'H' ], + [ path_on => 'A', 'H', 'D' ] ], ); sub load_into { my ($self, $solver) = @_; $solver->facts->{path_status} = DX::SetOver->new(over => 'path'); $solver->facts->{file_content} = DX::SetOver->new(over => 'path'); + $solver->facts->{env_dir} = DX::SetOver->new(over => 'path'); $solver->add_predicate( catdir => [ qw(DirPath DirName SubDirPath) ], [ qw(+ + -) ] => sub {