Panda3D
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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"

Classes

class  Results
 

Public Member Functions

 DSearchPath (const DSearchPath &copy)=default
 
 DSearchPath (const Filename &directory)
 
 DSearchPath (const std::string &path, const std::string &separator=std::string())
 
 DSearchPath (DSearchPath &&from)=default
 
void append_directory (const Filename &directory)
 Adds a new directory 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 append_path (const std::string &path, const std::string &separator=std::string())
 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.
 
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.
 
size_t find_all_files (const Filename &filename, Results &results) const
 Searches all the directories in the search list for the indicated file, in order.
 
Filename find_file (const Filename &filename) const
 Searches all the directories in the search list for the indicated file, in order.
 
const Filenameget_directory (size_t n) const
 
size_t get_num_directories () const
 
bool is_empty () const
 Returns true if the search list is empty, false otherwise.
 
DSearchPathoperator= (const DSearchPath &copy)=default
 
DSearchPathoperator= (DSearchPath &&from)=default
 
void output (std::ostream &out, const std::string &separator=std::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 (std::ostream &out, int indent_level=0) const
 

Static Public Member Functions

static Filename search_path (const Filename &filename, const std::string &path, const std::string &separator=std::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.
 

Public Attributes

 get_directory
 Returns the nth directory on the search list.
 
 get_num_directories
 Returns the number of directories on the search list.
 

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 28 of file dSearchPath.h.

Constructor & Destructor Documentation

◆ DSearchPath() [1/2]

DSearchPath::DSearchPath ( const std::string & path,
const std::string & separator = std::string() )

Definition at line 122 of file dSearchPath.cxx.

◆ DSearchPath() [2/2]

DSearchPath::DSearchPath ( const Filename & directory)

Definition at line 130 of file dSearchPath.cxx.

Member Function Documentation

◆ append_directory()

void DSearchPath::append_directory ( const Filename & directory)

◆ append_path() [1/2]

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 193 of file dSearchPath.cxx.

◆ append_path() [2/2]

void DSearchPath::append_path ( const std::string & path,
const std::string & separator = std::string() )

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

Definition at line 163 of file dSearchPath.cxx.

References append_directory().

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

◆ clear()

void DSearchPath::clear ( )

Removes all the directories from the search list.

Definition at line 138 of file dSearchPath.cxx.

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

◆ find_all_files() [1/2]

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 37 of file dSearchPath.I.

References find_all_files().

◆ find_all_files() [2/2]

size_t 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 283 of file dSearchPath.cxx.

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

Referenced by find_all_files().

◆ find_file()

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 243 of file dSearchPath.cxx.

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

Referenced by Filename::resolve_filename(), and search_path().

◆ is_empty()

bool DSearchPath::is_empty ( ) const

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

Definition at line 216 of file dSearchPath.cxx.

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

◆ output()

void DSearchPath::output ( std::ostream & out,
const std::string & separator = std::string() ) const

Definition at line 322 of file dSearchPath.cxx.

◆ prepend_directory()

void DSearchPath::prepend_directory ( const Filename & directory)

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

Definition at line 154 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::prepend_directory().

◆ prepend_path()

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 203 of file dSearchPath.cxx.

Referenced by ConfigVariableSearchPath::prepend_path().

◆ search_path()

Filename DSearchPath::search_path ( const Filename & filename,
const std::string & path,
const std::string & separator = std::string() )
inlinestatic

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 50 of file dSearchPath.I.

References find_file().

◆ write()

void DSearchPath::write ( std::ostream & out,
int indent_level = 0 ) const

Definition at line 346 of file dSearchPath.cxx.

Member Data Documentation

◆ get_directory

const Filename & DSearchPath::get_directory

Returns the nth directory on the search list.

Definition at line 76 of file dSearchPath.h.

Referenced by VirtualFileSystem::find_all_files(), VirtualFileSystem::find_file(), Filename::find_on_searchpath(), and ConfigPageManager::reload_implicit_pages().

◆ get_num_directories

size_t DSearchPath::get_num_directories

Returns the number of directories on the search list.

Definition at line 76 of file dSearchPath.h.

Referenced by VirtualFileSystem::find_all_files(), VirtualFileSystem::find_file(), Filename::find_on_searchpath(), and ConfigPageManager::reload_implicit_pages().


The documentation for this class was generated from the following files: