NAME
Util::Medley::File - utility file methods
VERSION
version 0.007
SYNOPSIS
my $file = Util::Medley::File->new;
my $basename = $file->basename($path);
my $dirname = $file->dirname($path);
my $newpath = $file->trimSuffix($path);
my ($dir, $filename, $suffix) = $file->parsePath($path);
$file->cp($src, $dest);
$file->mv($src, $dest);
$file->chmod($path);
$file->mkdir($path);
$file->rmdir($path);
$file->unlink($path);
my $prev_dir = $file->chdir($path);
my $type = $file->fileType($path);
my @found = $file->find($path);
my $cwd = $file->getcwd;
$file->xmllint(path => $path);
my $formated_xml = $file->xmllint(string => $myxml);
DESCRIPTION
Provides frequently used file operation methods. Many of these are pass-through to a standard 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.
- usage:
-
my @files = $file->find( dir => $dir, [ files_only => $bool ], [ dirs_only => $bool ]);
- args:
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.
rmdir
Delete a directory and any contents. Pass-through to File::Path::remove_tree().
trimExt
Trim the file extension from a filename.
unlink
Pass-through to CORE::unlink().
xmllint
Wrapper around the xmllint command. You can pass an xml string or the path to an xml file.