App-Pfind

 view release on metacpan or  search on metacpan

lib/App/Pfind.pm  view on Meta::CPAN

# This hash contains options that are global for the whole program.
my %options;

# Methods that are shared with the safe:

sub prune {
  die "The prune command cannot be used when --depth-first is set.\n" if $options{depth_first};
  $File::Find::prune = 1;
}
# The prototype means that $_ will be used if nothing else is passed.
sub mkdir(_;@) {
  my $err;
  make_path(@_, { error => \$err });
  # make_path sets $! on success (as it test the existance of the file).
  undef $!;
  $! = join(', ', @$err) if @$err;
}
sub rmdir(_;@) {
  for my $d (@_) {
    CORE::rmdir($d);
  }
}
# A safe 'rm' that does not recurse into directories.
sub rm(_;@) {
  for my $f (@_) {
    if (-d $f) {
      CORE::rmdir($f);
      return if $!;
    } else {
      my $err;
      remove_tree($f, { error => \$err });
      undef $!;
      $! = join(', ', @$err) if @$err;
    }
  }
}
sub rmtree(_;@) {
  my $err;
  remove_tree(@_, { error => \$err });
  undef $!;
  $! = join(', ', @$err) if @$err;
}

sub reset_options {
  $safe = Safe->new();
  $safe->deny_only(':ownprocess', ':others', ':dangerous');
  $safe->reval('use File::Spec::Functions qw(:ALL);');



( run in 0.646 second using v1.01-cache-2.11-cpan-65fba6d93b7 )