The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CGI::Bus::fut - File and directory utils library

SYNOPSIS

 use CGI::Bus;
 $s =CGI::Bus->new();
 $s->fut->mkdir(directory);

DESCRIPTION

This module contains several file and directory methods. See CGI::Bus::Base for inherited slots and methods.

CLASSIFICATION

Directory utils

copy, delete, find, glob, globn, mkdir, rmpath, size

File utils

fcompare, fhandle, fload, fstore, fdumpload, fdumpstore

SLOTS

    None

METHODS

copy (?-rdfi, fromMask, to) -> success

Copy files and directories. Options: 'r'ecurse subdirectories, 'd'irectory target hint, 'f'ile target hint, 'i'gnore errors - continue copying.

delete (?-ri, pathFileMask) -> success

Delete files and directories. Options: 'r'ecurse subdirectories, 'i'gnore errors - continue deleting.

fcompare ( ?-opt, file, file ) -> not equal

Compare files using File::Compare

fdump ( file, data ) -> success
fdump ( file ) -> data ref
fdumpstore ( file, data ref ) -> success
fdumpload ( file ) -> data ref

Store and load data structure to or from file using fstore, fload, CGI::Bus::dumpout, CGI::Bus::dumpin

fhandle ( file, sub{}) -> result

Selects given filehandle, evals sub, reselects previously selected handle. For filename, temporarily opens file with handle 'HANDLE', selects this handle, evals sub... Returns result of sub.

find ( ?-i!dlmrs, fileMask,..., sub(\@stat,path,name)...) -> num_matches

Find files and directories with given mask and evaluates sub, locally setting $_ to filename. Returns number of sub agrees. There may be several subs and several filemasks for each sub, and they will be executed within one transaction of find call. Uses FileGlob

Options: 'i'gnore stat errors, '!' - not, 'd'irectories, 'l'ow before deep scan, 'm'ountpoints, 'r'ecurse directories, 's'ymlinks.

Parameters of sub are local $_ with full current filename, $_[0] with reference to @stat array, $_[1] with path, $_[2] with filename. Sub can return undefined value in $_ to signal stop, determine directories with $_[0]->[2] & 0040000, prevent recursing by assigning $_[0]->[2] =0.

fload ( ?-asb, file, ?sub ) -> list of rows || data

Reads given file into memory as array or list ('-a'), text scalar ('-s'), binary scalar ('-b'). Default, '-a' or '-b', is determined with wantarray. Locks file with 'LOCK_SH'.

If sub is defined, it is evaluated for each row read into local $_, and with '-a' option results of each evaluation are returned as a list, true is returned otherwise.

fstore ( ?-b, file, data,...) -> success

Writes given data into given file. Locks file with 'LOCK_EX'. Option '-b' chooses binary mode and binary write. Without '-b', each element of data list is printed with trailing "\n" added. Prepend file name with '>' sign to append to file existed.

glob ( pathMask ) -> entry list

Glob filenames with mask and return list of them such as standard glob function. When $^O eq 'MSWin32' own implementation with fragments from File::DosGlob is used, else glob is called.

globn ( pathMask ) -> entry list

Like glob, but returns list of names only, without paths

mkdir ( path, ?perms ) -> success

Create path like standard mkdir call, but with base directories if needed, and optional permission mask (0777 default).

rmpath ( path ) -> success

Remove path, with base directories, if empty. Returns the number of directories deleted.

-size ( ?-i, pathMask ) -> size of files described

Compute size of files and directories. Uses find and it's options.

VERSION

21/12/2001 - 23/12/2001

Implemented and Documented.

AUTHOR

Andrew V Makarow <makarow at mail.com>

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 167:

You forgot a '=back' before '=head1'

Around line 171:

You forgot a '=back' before '=head2'

Around line 177:

=back without =over