Panda3D
Classes | Public Member Functions | Static Public Member Functions

DSearchPath Class Reference

This class stores a list of directories that can be searched, in order, to locate a particular file. More...

#include "dSearchPath.h"

List of all members.

Classes

class  Results

Public Member Functions

 DSearchPath ()
 Creates an empty search path.
 DSearchPath (const string &path, const string &separator=string())
 DSearchPath (const DSearchPath &copy)
 DSearchPath (const Filename &directory)
void append_directory (const Filename &directory)
 Adds a new directory to the end of the search list.
void append_path (const string &path, const string &separator=string())
 Adds all of the directories listed in the search path to the end of the search list.
void append_path (const DSearchPath &path)
 Adds all of the directories listed in the search path to the end of the search list.
void clear ()
 Removes all the directories from the search list.
int find_all_files (const Filename &filename, Results &results) const
 Searches all the directories in the search list for the indicated file, in order.
Results find_all_files (const Filename &filename) const
 This variant of find_all_files() returns the new Results object, instead of filling on in on the parameter list.
Filename find_file (const Filename &filename) const
 Searches all the directories in the search list for the indicated file, in order.
const Filenameget_directory (int n) const
 Returns the nth directory on the search list.
int get_num_directories () const
 Returns the number of directories on the search list.
bool is_empty () const
 Returns true if the search list is empty, false otherwise.
 MAKE_SEQ (get_directories, get_num_directories, get_directory)
void operator= (const DSearchPath &copy)
void output (ostream &out, const string &separator=string()) const
void prepend_directory (const Filename &directory)
 Adds a new directory to the front of the search list.
void prepend_path (const DSearchPath &path)
 Adds all of the directories listed in the search path to the beginning of the search list.
void write (ostream &out, int indent_level=0) const

Static Public Member Functions

static Filename search_path (const Filename &filename, const string &path, const string &separator=string())
 A quick-and-easy way to search a searchpath for a file when you don't feel like building or keeping around a DSearchPath object.

Detailed Description

This class stores a list of directories that can be searched, in order, to locate a particular file.

It is normally constructed by passing it a traditional searchpath-style string, e.g. a list of directory names delimited by spaces or colons, but it can also be built up explicitly.

Definition at line 32 of file dSearchPath.h.


Constructor & Destructor Documentation

DSearchPath::DSearchPath ( )

Creates an empty search path.

Definition at line 143 of file dSearchPath.cxx.


Member Function Documentation

void DSearchPath::append_directory ( const Filename directory)
void DSearchPath::append_path ( const string &  path,
const string &  separator = string() 
)

Adds all of the directories listed in the search path to the end of the search list.

Definition at line 233 of file dSearchPath.cxx.

References append_directory(), and Filename::from_os_specific().

Referenced by ConfigVariableSearchPath::append_path(), and FltHeader::convert_path().

void DSearchPath::append_path ( const DSearchPath path)

Adds all of the directories listed in the search path to the end of the search list.

Definition at line 265 of file dSearchPath.cxx.

void DSearchPath::clear ( )

Removes all the directories from the search list.

Definition at line 202 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::clear_local_value(), and ConfigPageManager::reload_implicit_pages().

int DSearchPath::find_all_files ( const Filename filename,
DSearchPath::Results results 
) const

Searches all the directories in the search list for the indicated file, in order.

Fills up the results list with *all* of the matching filenames found, if any. Returns the number of matches found.

It is the responsibility of the the caller to clear the results list first; otherwise, the newly-found files will be appended to the list.

Definition at line 372 of file dSearchPath.cxx.

References DSearchPath::Results::add_file(), Filename::is_fully_qualified(), and Filename::is_local().

Referenced by ConfigVariableSearchPath::find_all_files(), and find_all_files().

DSearchPath::Results DSearchPath::find_all_files ( const Filename filename) const [inline]

This variant of find_all_files() returns the new Results object, instead of filling on in on the parameter list.

This is a little more convenient to call from Python.

Definition at line 49 of file dSearchPath.I.

References find_all_files().

Filename DSearchPath::find_file ( const Filename filename) const

Searches all the directories in the search list for the indicated file, in order.

Returns the full matching pathname of the first match if found, or the empty string if not found.

Definition at line 327 of file dSearchPath.cxx.

References Filename::is_fully_qualified(), and Filename::is_local().

Referenced by ConfigVariableSearchPath::find_file(), and search_path().

const Filename & DSearchPath::get_directory ( int  n) const

Returns the nth directory on the search list.

Definition at line 313 of file dSearchPath.cxx.

Referenced by VirtualFileSystem::find_all_files(), ConfigVariableSearchPath::get_directory(), and ConfigPageManager::reload_implicit_pages().

int DSearchPath::get_num_directories ( ) const

Returns the number of directories on the search list.

Definition at line 303 of file dSearchPath.cxx.

Referenced by VirtualFileSystem::find_all_files(), ConfigVariableSearchPath::get_num_directories(), and ConfigPageManager::reload_implicit_pages().

bool DSearchPath::is_empty ( ) const

Returns true if the search list is empty, false otherwise.

Definition at line 293 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::clear_local_value(), PathReplace::is_empty(), ConfigVariableSearchPath::is_empty(), and ConfigPageManager::reload_implicit_pages().

void DSearchPath::prepend_directory ( const Filename directory)

Adds a new directory to the front of the search list.

Definition at line 222 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::prepend_directory().

void DSearchPath::prepend_path ( const DSearchPath path)

Adds all of the directories listed in the search path to the beginning of the search list.

Definition at line 277 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::prepend_path().

Filename DSearchPath::search_path ( const Filename filename,
const string &  path,
const string &  separator = string() 
) [inline, static]

A quick-and-easy way to search a searchpath for a file when you don't feel like building or keeping around a DSearchPath object.

This simply constructs a temporary DSearchPath based on the indicated path string, and searches that.

Definition at line 65 of file dSearchPath.I.

References find_file().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations