PET::Util::IO

PET::Util::IO

General IO class, mostly to simplify file and directory access.  Of course there is Slurp, IO :: *, etc. which are much better, full-blown classes - however, this one has no external dependency (except for Digest::MD5, which is mandatory for PET anyway).

Summary
PET::Util::IOGeneral IO class, mostly to simplify file and directory access.
Functions
NAMEMandatory for PET::Util classes.
getDir (%p)Returns a list of files in a given directory (arrayref of hashrefs).
readLangHash ($path)FIXME.
slurp ($filename)Reads in a file.
loadFile ($file, %params)Loads a file.
copyFile ($src, $dst, %p)Copy file using absolute paths.

Functions

NAME

sub NAME

Mandatory for PET::Util classes.

getDir (%p)

sub getDir

Returns a list of files in a given directory (arrayref of hashrefs).

Parameters

dirthe directory; absolute or BASEPATH relative
recurseenter subdirectories (this makes an array of array of...); default is 0 (no)
filesonlylist only files; default is 1 (yes)
dirsonlylist only dirs; default is 0 (no)
extlist files only by this extension; default is undef
extilist files only by this extension (case insensitive); default is undef
matchrematch filenames for this regexp; default is undef
absolutereturn absolute paths; default is 0, returns relative paths
nodirdiesdies if the dir does not exist, or is unreadable; defaults to 0 (no)
readdescreads “$filename.desc” file for each entry, putting “key:valune\n**\n” into the “desc” hash value of this parameter defines the extension

Both ext and exti can be given as a “junction”, like “jpg|jpeg”.

Returns “undef” if the file does not exist, [] if no matching files.  Dies on wrong parameters.  A hash contains: “name”,”path”, [“desc” : if requested]

FIXME: recurse does not work as of yet.

readLangHash ($path)

sub readLangHash

FIXME.

slurp ($filename)

sub slurp

Reads in a file.  Calls loadFile.  This is a simplified call, it does not handle errors: undef is returned if the file is unopenable.

loadFile ($file, %params)

sub loadFile

Loads a file.  Returns a scalarref if succeful, or a scaler with an error message if there was an error.

Params are not yhet handled (e.g.  ‘dieonerror’, ‘maxsize’).

copyFile ($src, $dst, %p)

sub copyFile

Copy file using absolute paths.  %p can define behaviour.  FIXME: %p is yet undefined.

This can be called as a class method, too.

Base class for all Util modules.
sub NAME
Mandatory for PET::Util classes.
sub getDir
Returns a list of files in a given directory (arrayref of hashrefs).
sub readLangHash
FIXME.
sub slurp
Reads in a file.
sub loadFile
Loads a file.
sub copyFile
Copy file using absolute paths.
Close