Panda3D
|
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models and textures from a file with correct pathnames. More...
#include "pathReplace.h"
Classes | |
class | Component |
class | Entry |
Public Member Functions | |
void | add_pattern (const string &orig_prefix, const string &replacement_prefix) |
Adds the indicated original/replace pattern to the specification. | |
void | clear () |
Removes all the patterns from the specification. | |
void | clear_error () |
Resets the error flag to the no-error state. | |
Filename | convert_path (const Filename &orig_filename, const DSearchPath &additional_path=DSearchPath()) |
Calls match_path() followed by store_path(), to replace the initial prefix and then convert the file for storing, as the user indicated. | |
void | full_convert_path (const Filename &orig_filename, const DSearchPath &additional_path, Filename &resolved_path, Filename &output_path) |
Converts the input path into two different forms: A resolved path, and an output path. | |
int | get_num_patterns () const |
Returns the number of original/replace patterns that have been added. | |
const string & | get_orig_prefix (int n) const |
Returns the original prefix associated with the nth pattern. | |
const string & | get_replacement_prefix (int n) const |
Returns the replacement prefix associated with the nth pattern. | |
bool | had_error () const |
Returns true if an error was detected since the last call to clear_error(), false otherwise. | |
bool | is_empty () const |
Returns true if the PathReplace object specifies no action, or false if convert_path() may do something. | |
Filename | match_path (const Filename &orig_filename, const DSearchPath &additional_path=DSearchPath()) |
Looks for a match for the given filename among all the replacement patterns, and returns the first match found. | |
Filename | store_path (const Filename &orig_filename) |
Given a path to an existing filename, converts it as specified in the _path_store and or _path_directory properties to a form suitable for storing in an output file. | |
void | write (ostream &out, int indent_level=0) const |
Public Attributes | |
bool | _copy_files |
Filename | _copy_into_directory |
bool | _exists |
bool | _noabs |
DSearchPath | _path |
Filename | _path_directory |
PathStore | _path_store |
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models and textures from a file with correct pathnames.
It corresponds to a sequence of -pr command-line options, as well as the -pp option.
This can also go the next step, which is to convert a known file into a suitable form for storing in a model file. In this capacity, it corresponds to the -ps and -pd options.
Definition at line 40 of file pathReplace.h.
void PathReplace::add_pattern | ( | const string & | orig_prefix, |
const string & | replacement_prefix | ||
) | [inline] |
Adds the indicated original/replace pattern to the specification.
If a filename is encountered whose initial prefix matches the indicated orig_prefix, that prefix will be replaced with replacement_prefix.
Definition at line 59 of file pathReplace.I.
Referenced by ProgramBase::dispatch_path_replace().
void PathReplace::clear | ( | void | ) | [inline] |
Removes all the patterns from the specification.
Definition at line 45 of file pathReplace.I.
References clear_error().
void PathReplace::clear_error | ( | ) | [inline] |
Resets the error flag to the no-error state.
had_error() will return false until a new error is generated.
Definition at line 24 of file pathReplace.I.
Referenced by clear().
Filename PathReplace::convert_path | ( | const Filename & | orig_filename, |
const DSearchPath & | additional_path = DSearchPath() |
||
) | [inline] |
Calls match_path() followed by store_path(), to replace the initial prefix and then convert the file for storing, as the user indicated.
Definition at line 117 of file pathReplace.I.
References full_convert_path().
void PathReplace::full_convert_path | ( | const Filename & | orig_filename, |
const DSearchPath & | additional_path, | ||
Filename & | resolved_path, | ||
Filename & | output_path | ||
) |
Converts the input path into two different forms: A resolved path, and an output path.
The resolved path is an absolute path if at all possible. The output path is in the form specified by the -ps path store option.
Definition at line 215 of file pathReplace.cxx.
References VirtualFileSystem::exists(), Filename::get_basename(), VirtualFileSystem::get_global_ptr(), Filename::is_fully_qualified(), Filename::is_local(), and VirtualFileSystem::resolve_filename().
Referenced by convert_path(), and EggBase::convert_paths().
int PathReplace::get_num_patterns | ( | ) | const [inline] |
Returns the number of original/replace patterns that have been added.
Definition at line 70 of file pathReplace.I.
const string & PathReplace::get_orig_prefix | ( | int | n | ) | const [inline] |
Returns the original prefix associated with the nth pattern.
Definition at line 81 of file pathReplace.I.
const string & PathReplace::get_replacement_prefix | ( | int | n | ) | const [inline] |
Returns the replacement prefix associated with the nth pattern.
Definition at line 93 of file pathReplace.I.
bool PathReplace::had_error | ( | ) | const [inline] |
Returns true if an error was detected since the last call to clear_error(), false otherwise.
Definition at line 35 of file pathReplace.I.
bool PathReplace::is_empty | ( | ) | const [inline] |
Returns true if the PathReplace object specifies no action, or false if convert_path() may do something.
Definition at line 105 of file pathReplace.I.
References DSearchPath::is_empty().
Filename PathReplace::match_path | ( | const Filename & | orig_filename, |
const DSearchPath & | additional_path = DSearchPath() |
||
) |
Looks for a match for the given filename among all the replacement patterns, and returns the first match found.
If additional_path is nonempty, it is an additional search path on which to look for the file. The model_path is always implicitly searched.
Definition at line 54 of file pathReplace.cxx.
References VirtualFileSystem::exists(), VirtualFileSystem::get_global_ptr(), Filename::is_fully_qualified(), Filename::is_local(), and VirtualFileSystem::resolve_filename().
Filename PathReplace::store_path | ( | const Filename & | orig_filename | ) |
Given a path to an existing filename, converts it as specified in the _path_store and or _path_directory properties to a form suitable for storing in an output file.
Definition at line 162 of file pathReplace.cxx.
References Filename::get_basename(), and Filename::is_local().