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"
Public Member Functions | |
void | add_pattern (const string &orig_prefix, const string &replacement_prefix) |
Adds the indicated original/replace pattern to the specification. More... | |
void | clear () |
Removes all the patterns from the specification. More... | |
void | clear_error () |
Resets the error flag to the no-error state. More... | |
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. More... | |
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. More... | |
int | get_num_patterns () const |
Returns the number of original/replace patterns that have been added. More... | |
const string & | get_orig_prefix (int n) const |
Returns the original prefix associated with the nth pattern. More... | |
const string & | get_replacement_prefix (int n) const |
Returns the replacement prefix associated with the nth pattern. More... | |
bool | had_error () const |
Returns true if an error was detected since the last call to clear_error(), false otherwise. More... | |
bool | is_empty () const |
Returns true if the PathReplace object specifies no action, or false if convert_path() may do something. More... | |
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. More... | |
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. More... | |
void | write (ostream &out, int indent_level=0) const |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Public Attributes | |
bool | _copy_files |
Filename | _copy_into_directory |
bool | _exists |
bool | _noabs |
DSearchPath | _path |
Filename | _path_directory |
PathStore | _path_store |
Additional Inherited Members | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
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.
|
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.
References get_num_patterns().
Referenced by clear(), and ProgramBase::get_exec_command().
|
inline |
Removes all the patterns from the specification.
Definition at line 45 of file pathReplace.I.
References add_pattern(), and clear_error().
Referenced by had_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.
References had_error().
Referenced by clear().
|
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().
Referenced by is_empty().
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::copy_file(), VirtualFileSystem::exists(), Filename::extract_components(), Filename::get_basename(), DSearchPath::get_directory(), VirtualFileSystem::get_global_ptr(), DSearchPath::get_num_directories(), Filename::is_fully_qualified(), Filename::is_local(), Filename::make_absolute(), VirtualFileSystem::make_directory_full(), Filename::make_relative_to(), and VirtualFileSystem::resolve_filename().
Referenced by convert_path(), EggBase::convert_paths(), and store_path().
|
inline |
Returns the number of original/replace patterns that have been added.
Definition at line 70 of file pathReplace.I.
References get_orig_prefix().
Referenced by add_pattern().
|
inline |
Returns the original prefix associated with the nth pattern.
Definition at line 81 of file pathReplace.I.
References get_replacement_prefix().
Referenced by get_num_patterns().
|
inline |
Returns the replacement prefix associated with the nth pattern.
Definition at line 93 of file pathReplace.I.
References is_empty().
Referenced by get_orig_prefix().
|
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.
References clear().
Referenced by clear_error().
|
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 convert_path(), and DSearchPath::is_empty().
Referenced by get_replacement_prefix().
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(), VirtualFileSystem::resolve_filename(), and store_path().
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 full_convert_path(), Filename::get_basename(), Filename::is_local(), Filename::make_absolute(), and Filename::make_relative_to().
Referenced by match_path().