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


CGI-Bus documentation  | view source Contained in the CGI-Bus distribution.

Index


NAME

Top

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

SYNOPSIS

Top

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

DESCRIPTION

Top

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

CLASSIFICATION

Top

Directory utils

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

File utils

fcompare, fhandle, fload, fstore, fdumpload, fdumpstore

SLOTS

Top

None

METHODS

Top

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 (Compare in File)

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 (wantarray in perlfunc). 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 (DosGlob in File) 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 (mkdir in perlfunc) 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

Top

21/12/2001 - 23/12/2001

Implemented and Documented.

AUTHOR

Top

Andrew V Makarow <makarow at mail.com>


CGI-Bus documentation  | view source Contained in the CGI-Bus distribution.