DSearchPath

class DSearchPath

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.

Inheritance diagram

Inheritance diagram of DSearchPath

class Results
Results(void)
Results(DSearchPath::Results const &copy)
void clear(void)

Removes all the files from the list.

Filename const &get_file(std::size_t n) const

Returns the nth file on the result list.

std::size_t get_num_files(void) const

Returns the number of files on the result list.

void output(std::ostream &out) const
std::size_t size(void) const

Returns the num of filenames in the set. This method is defined to make the Results object appear to be a list in Python.

void write(std::ostream &out, int indent_level = 0) const
DSearchPath(void) = default
DSearchPath(std::string const &path, std::string const &separator = string())
DSearchPath(Filename const &directory)
DSearchPath(DSearchPath const &copy) = default
void append_directory(Filename const &directory)

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

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

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

void clear(void)

Removes all the directories from the search list.

std::size_t find_all_files(Filename const &filename, Results &results) const
Results find_all_files(Filename const &filename) const

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.

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.

Filename find_file(Filename const &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.

Filename const &get_directory(std::size_t n) const

Returns the nth directory on the search list.

std::size_t get_num_directories(void) const

Returns the number of directories on the search list.

bool is_empty(void) const

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

void output(std::ostream &out, std::string const &separator = string()) const
void prepend_directory(Filename const &directory)

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

void prepend_path(DSearchPath const &path)

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

Filename search_path(Filename const &filename, std::string const &path, std::string const &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. This simply constructs a temporary DSearchPath based on the indicated path string, and searches that.

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