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

NAME

App::Framework::Base::SearchPath - Searchable path

SYNOPSIS

use App::Framework::Base::SearchPath ;

DESCRIPTION

Provides a simple searchable path under which to locate files or directories.

When trying the read a file/dir, looks in each location in the path stopping at the first found.

When writing a file/dir, attempts to write into each location in the path until can either (a) write, or (b) runs out of search path

FIELDS

The following fields should be defined either in the call to 'new()', as part of a 'set()' call, or called by their accessor method (which is the same name as the field):

dir_mask - directory creation mask

When the write_path is searched, any directories created are created using this mask [default = 0755]

env - environment HASH ref

Any paths that contain variables have the variables expanded using the standard environment variables. Specifying this HASH ref causes the variables to be replaced from this HASH before looking in the envrionment.

path - search path

A comma seperated list (in scalar context), or an ARRAY ref list of paths to be searched (for a file)

write_path - search path for writing

A comma seperated list (in scalar context), or an ARRAY ref list of paths to be searched (for a file) when writing. If not set, then path is used.

CONSTRUCTOR

new([%args])

Create a new SearchPath object.

The %args are specified as they would be in the set method, for example:

        'mmap_handler' => $mmap_handler

The full list of possible arguments are :

        'fields'        => Either ARRAY list of valid field names, or HASH of field names with default values 

CLASS METHODS

init_class([%args])

Initialises the SearchPath object class variables.

OBJECT METHODS

path([$path])

Get/set the search path. When setting, can either be:

  • comma/semicolon seperated list of directories

  • ARRAY ref to list of directories

When getting in scalar context returns comma seperated list; otherwise returns an ARRAY.

write_path([$path])

Get/set the write path. Set the path for writing file/dir. If this is not set then uses 'path'. You can set this to something different to ensure that created files are limited to user home directory (for example).

When setting, can either be:

  • comma/semicolon seperated list of directories

  • ARRAY ref to list of directories

When getting in scalar context returns comma seperated list; otherwise returns an ARRAY.

read_filepath($file)

Search through the search path attempting to read $file. Returns the file path to the readable file if found; otherwise returns undef

write_filepath($file)

Search through the search path attempting to write $file. Returns the file path to the writeable file if found; otherwise returns undef

DIAGNOSTICS

Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.

AUTHOR

Steve Price <sdprice at cpan.org>

BUGS

None that I know of!