++ed by:
ABRAXXA KEEDI

2 PAUSE user(s)
1 non-PAUSE user(s).

Ash Berlin

NAME

Catalyst::Model::File - File based storage model for Catalyst.

SYNOPSIS

# use the helper to create a model myapp_create.pl model File File

# configure in lib/MyApp.pm

    MyApp->config(
        name          => 'MyApp',
        root          => MyApp->path_to('root'),
        'Model::File' => {
            root_dir => MyApp->path_to('file_store')
        },
    );

Simple file based storage model for Catalyst.

  @file_names = $c->model('File')->list;

METHODS

list

Returns a list of files (and/or directories) found under the current working dir. Default will return files (including those found under sub-directories) but not directories.

To change this behaviour specify a mode param of files (default), dirs or both:

 $mdl->list(mode => 'both')

To only get files/dirs directly under the current dir specify a recurse option of 0.

Please note: the exact order in which files and directories are listed will change from OS to OS.

change_dir

cd

Set current working directory (relative to current) and return $self.

directory

pwd

Get the current working directory, from which all relative paths are based.

parent

Move up to the parent of the working directory. Returns $self.

$self->file($file)

Returns an Path::Class::File object of $file (which can be a string or a Class::Path::File object,) or undef if the file is an invalid path - i.e. outside the directory structure specified in the config.

$self->slurp($file)

Shortcut to $self->file($file)->slurp.

In a scalar context, returns the contents of $file in a string. In a list context, returns the lines of $file (according to how $/ is set) as a list. If the file can't be read, this method will throw an exception.

If you want "chomp()" run on each line of the file, pass a true value for the "chomp" or "chomped" parameters:

 my @lines = $self->slurp($file, chomp => 1);

$self->splat($file, PRINT_ARGS)

Does a print to $file with the specified PRINT_ARGS. Does the same as $self-file->openw->print(@_)>

AUTHOR

Ash Berlin, ash@cpan.org

LICENSE

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.




Hosting generously
sponsored by Bytemark