++ed by:

2 PAUSE users
1 non-PAUSE user.

Ash Berlin


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


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

# configure in lib/MyApp.pm

        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;



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.



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



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


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


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.


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(@_)>


Ash Berlin, ash@cpan.org


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