NAME
Util::Medley::File - utility file methods
VERSION
version 0.009
SYNOPSIS
my $util = Util::Medley::File->new;
my $basename = $util->basename($path);
my $dirname = $util->dirname($path);
my $newpath = $util->trimSuffix($path);
my ($dir, $utilname, $suffix) = $util->parsePath($path);
$util->cp($src, $dest);
$util->mv($src, $dest);
$util->chmod($path);
$util->mkdir($path);
$util->rmdir($path);
$util->unlink($path);
my $prev_dir = $util->chdir($path);
my $type = $util->fileType($path);
my @found = $util->find($path);
my $cwd = $util->getcwd;
DESCRIPTION
Provides frequently used file operation methods. Many of these are pass-through to another module. Others offer variations on the originals. All methods output debug logging statements when enabled. Any errors are bubbled up with Carp::confess(). Use eval as appropriate.
METHODS
basename
Pass-through to File::Path::basename().
chdir
Pass-through to CORE::chdir(), but differs in that it returns the original dir.
chmod
Pass-through to CORE::chmod().
cp
Pass-through to File::Copy::copy().
dirname
Pass-through to File::Path::dirname().
fileType
Get the filetype of a file.
find
Pass-through to Path::Iterator::Rule. Returns a list of all files and directories.
findFiles
Returns a list of all files under a given directory. Just a convenience wrapper around find.
findDirs
Returns a list of all directories under a given directory. Just a convenience wrapper around find.
getcwd
Pass-through to Cwd::getcwd().
mkdir
Pass-through to File::Path::make_path().
mv
Pass-through to File::Copy::move().
parsePath
Parse a file path into directory, filename, and extension. This is a pass-through to File::Basename::fileparse, but it additional trims the '.' from the extension and extraneous trailing /'s in the dir.
- usage:
-
($dir, $name, $ext) = $util->parsePath($path); ($dir, $name, $ext) = $util->parsePath(path => $path);
- args:
rmdir
Delete a directory and any contents. Pass-through to File::Path::remove_tree().
trimExt
Trim the file extension from a filename.
- usage:
-
$filename_no_ext = $util->trimExt($filename); $filename_no_ext = $util->trimExt(name => $filename);
- args:
unlink
Pass-through to CORE::unlink().