++ed by:
KEEDI

1 PAUSE user(s)

Lionel Cons

NAME

No::Worries::Dir - directory handling without worries

SYNOPSIS

  use No::Worries::Dir
      qw(dir_change dir_ensure dir_make dir_parent dir_read dir_remove);

  # change directory
  dir_change("/tmp");

  # make sure a directory exists (not an error if it exists already)
  dir_ensure("/tmp/some/path", mode => oct(770));

  # make a directory (an error if it exists already)
  dir_make("/tmp/some/path", mode => oct(770));

  # find out the parent directory of some path
  $parent = dir_parent($path);
  dir_ensure($parent);

  # read a directory
  foreach $name (dir_read("/etc")) {
      ...
  }

  # remove a directory
  dir_remove("/tmp/some/path");

DESCRIPTION

This module eases directory handling by providing convenient wrappers around standard directory functions. All the functions die() on error.

FUNCTIONS

This module provides the following functions (none of them being exported by default):

dir_change(PATH)

change the working directory to the given path; this is a safe thin wrapper on top of chdir()

dir_ensure(PATH[, OPTIONS])

make sure the given path is an existing directory, creating it (including its parents) if needed; supported options:

  • mode: numerical mode to use for mkdir() (default: oct(777))

dir_make(PATH[, OPTIONS])

make the given directory; this is a safe thin wrapper on top of mkdir(); supported options:

  • mode: numerical mode to use for mkdir() (default: oct(777))

dir_parent(PATH)

return the parent directory of the given path

dir_read(PATH)

read the given directory and return its list of entries except . and ..

dir_remove(PATH)

remove the given directory (that must exist and be empty); this is a safe thin wrapper on top of rmdir()

SEE ALSO

No::Worries.

AUTHOR

Lionel Cons http://cern.ch/lionel.cons

Copyright (C) CERN 2012-2014