use aliased 'DX::Lib::FS::Fact::PathStatus';
use aliased 'DX::Lib::FS::Fact::PathStatusInfo';
-use POSIX qw(ENOENT);
-use File::stat;
+use DX::Lib::FS::Guts;
use Moo;
has path => (is => 'ro', required => 1);
sub run {
my ($self) = @_;
- if (my $stat = stat(my $path = $self->path)) {
- (path_status => PathStatus->new(
- path => $path,
- info => PathStatusInfo->new(
- is_directory => -d _,
- is_file => -f _,
- mode => sprintf("%04o", ($stat->mode & 07777)),
- )
- ));
- } elsif ($! == ENOENT) {
- (path_status => PathStatus->new(path => $path));
- } else {
- die "Couldn't stat ${path}: $!";
- }
+ my $info = DX::Lib::FS::Guts->path_status_info($self->path);
+ (path_status => PathStatus->new(
+ path => $self->path,
+ ($info
+ ? (info => PathStatusInfo->new($info))
+ : ()
+ )
+ ));
}
1;