App-Framework

 view release on metacpan or  search on metacpan

lib/App/Framework/Base/SearchPath.pm  view on Meta::CPAN


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

=item B<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
B<path> is used.


=back

=cut


my %FIELDS = (
	# user settings
	'dir_mask'		=> 0755,
	'env'			=> {},
	
	# Object Data
	'path'			=> undef,	# dummy field - causes _path to be set
	'write_path'	=> undef,	# dummy field - casues _write_path to be set
	
	'_path'			=> [],
	'_write_path'	=> undef,
) ;



#============================================================================================

=head2 CONSTRUCTOR

=over 4

=cut

#============================================================================================

=item B< new([%args]) >

Create a new SearchPath object.

The %args are specified as they would be in the B<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 

=cut

sub new
{
	my ($obj, %args) = @_ ;
	
	my $class = ref($obj) || $obj ;

	# Create object
	my $this = $class->SUPER::new(%args) ;

#$this->debug(2) ;
$this->_dbg_prt(["new this=", $this], 10) ;

	return($this) ;
}



#============================================================================================

=back

=head2 CLASS METHODS

=over 4

=cut

#============================================================================================

#-----------------------------------------------------------------------------

=item B< init_class([%args]) >

Initialises the SearchPath object class variables.

=cut

sub init_class
{
	my $class = shift ;
	my (%args) = @_ ;

	# Add extra fields
	$class->add_fields(\%FIELDS, \%args) ;

	# init class
	$class->SUPER::init_class(%args) ;

}

#============================================================================================

=back

=head2 OBJECT METHODS

=over 4

=cut

#============================================================================================

#----------------------------------------------------------------------------

=item B< path([$path]) >

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

=over 4

=item * comma/semicolon seperated list of directories

=item * ARRAY ref to list of directories

=back

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

=cut

sub path
{
	my $this = shift ;
	my ($path_ref) = @_ ;

	$path_ref ||= '' ;
$this->_dbg_prt(["path($path_ref)\n"]) ;
$this->_dbg_prt(["this=", $this], 10) ;
	
	my $list_aref = $this->_access_path('_path', $path_ref) ;

	return wantarray ? @$list_aref : join ',', @$list_aref ;
}

#----------------------------------------------------------------------------

=item B< 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:

=over 4

=item * comma/semicolon seperated list of directories



( run in 1.557 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )