mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
use <auto> filename path
This commit is contained in:
parent
c486e2b643
commit
1addfb29d8
@ -20,8 +20,10 @@
|
|||||||
|
|
||||||
static Filename resolve_dso(const DSearchPath &path, const Filename &filename) {
|
static Filename resolve_dso(const DSearchPath &path, const Filename &filename) {
|
||||||
if (filename.is_local()) {
|
if (filename.is_local()) {
|
||||||
if (path.is_empty()||
|
if ((path.get_num_directories()==1)&&(path.get_directory(0)=="<auto>")) {
|
||||||
((path.get_num_directories()==1)&&(path.get_directory(0)=="."))) {
|
// This is a special case, meaning to search in the same
|
||||||
|
// directory in which libp3dtool.dll, or the exe, was started
|
||||||
|
// from.
|
||||||
Filename dtoolpath = ExecutionEnvironment::get_dtool_name();
|
Filename dtoolpath = ExecutionEnvironment::get_dtool_name();
|
||||||
DSearchPath spath(dtoolpath.get_dirname());
|
DSearchPath spath(dtoolpath.get_dirname());
|
||||||
return spath.find_file(filename);
|
return spath.find_file(filename);
|
||||||
|
@ -30,6 +30,59 @@ ConfigVariableSearchPath(const string &name,
|
|||||||
#else
|
#else
|
||||||
ConfigVariableBase(name, VT_search_path, string(), flags),
|
ConfigVariableBase(name, VT_search_path, string(), flags),
|
||||||
#endif
|
#endif
|
||||||
|
_default_value(Filename(".")),
|
||||||
|
_local_modified(initial_invalid_cache())
|
||||||
|
{
|
||||||
|
// A SearchPath variable implicitly defines a default value of the empty
|
||||||
|
// string. This is just to prevent the core variable from
|
||||||
|
// complaining should anyone ask for its solitary value.
|
||||||
|
if (_core->get_default_value() == (ConfigDeclaration *)NULL) {
|
||||||
|
_core->set_default_value("");
|
||||||
|
}
|
||||||
|
_core->set_used();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableSearchPath::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE ConfigVariableSearchPath::
|
||||||
|
ConfigVariableSearchPath(const string &name,
|
||||||
|
const DSearchPath &default_value,
|
||||||
|
const string &description, int flags) :
|
||||||
|
#ifdef PRC_SAVE_DESCRIPTIONS
|
||||||
|
ConfigVariableBase(name, VT_search_path, description, flags),
|
||||||
|
#else
|
||||||
|
ConfigVariableBase(name, VT_search_path, string(), flags),
|
||||||
|
#endif
|
||||||
|
_default_value(default_value),
|
||||||
|
_local_modified(initial_invalid_cache())
|
||||||
|
{
|
||||||
|
// A SearchPath variable implicitly defines a default value of the empty
|
||||||
|
// string. This is just to prevent the core variable from
|
||||||
|
// complaining should anyone ask for its solitary value.
|
||||||
|
if (_core->get_default_value() == (ConfigDeclaration *)NULL) {
|
||||||
|
_core->set_default_value("");
|
||||||
|
}
|
||||||
|
_core->set_used();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableSearchPath::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE ConfigVariableSearchPath::
|
||||||
|
ConfigVariableSearchPath(const string &name,
|
||||||
|
const string &default_value,
|
||||||
|
const string &description, int flags) :
|
||||||
|
#ifdef PRC_SAVE_DESCRIPTIONS
|
||||||
|
ConfigVariableBase(name, VT_search_path, description, flags),
|
||||||
|
#else
|
||||||
|
ConfigVariableBase(name, VT_search_path, string(), flags),
|
||||||
|
#endif
|
||||||
|
_default_value(Filename(default_value)),
|
||||||
_local_modified(initial_invalid_cache())
|
_local_modified(initial_invalid_cache())
|
||||||
{
|
{
|
||||||
// A SearchPath variable implicitly defines a default value of the empty
|
// A SearchPath variable implicitly defines a default value of the empty
|
||||||
@ -74,6 +127,16 @@ get_value() const {
|
|||||||
return _cache;
|
return _cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableSearchPath::get_default_value
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE const DSearchPath &ConfigVariableSearchPath::
|
||||||
|
get_default_value() const {
|
||||||
|
return _default_value;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: ConfigVariableSearchPath::clear_local_value
|
// Function: ConfigVariableSearchPath::clear_local_value
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -46,10 +46,11 @@ reload_search_path() {
|
|||||||
_cache.append_directory(Filename::from_os_specific(expanded));
|
_cache.append_directory(Filename::from_os_specific(expanded));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cache.append_path(_postfix);
|
|
||||||
|
|
||||||
if (_cache.is_empty()) {
|
if (num_unique_references == 0) {
|
||||||
// An empty search path implicitly has "." on it.
|
// An empty search path implicitly has the default value.
|
||||||
_cache.append_directory(".");
|
_cache = _default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cache.append_path(_postfix);
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,19 @@ PUBLISHED:
|
|||||||
INLINE ConfigVariableSearchPath(const string &name,
|
INLINE ConfigVariableSearchPath(const string &name,
|
||||||
const string &description = string(),
|
const string &description = string(),
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
INLINE ConfigVariableSearchPath(const string &name,
|
||||||
|
const DSearchPath &default_value,
|
||||||
|
const string &description,
|
||||||
|
int flags = 0);
|
||||||
|
INLINE ConfigVariableSearchPath(const string &name,
|
||||||
|
const string &default_value,
|
||||||
|
const string &description,
|
||||||
|
int flags = 0);
|
||||||
INLINE ~ConfigVariableSearchPath();
|
INLINE ~ConfigVariableSearchPath();
|
||||||
|
|
||||||
INLINE operator const DSearchPath & () const;
|
INLINE operator const DSearchPath & () const;
|
||||||
INLINE const DSearchPath &get_value() const;
|
INLINE const DSearchPath &get_value() const;
|
||||||
|
INLINE const DSearchPath &get_default_value() const;
|
||||||
|
|
||||||
INLINE bool clear_local_value();
|
INLINE bool clear_local_value();
|
||||||
|
|
||||||
@ -77,6 +86,7 @@ PUBLISHED:
|
|||||||
private:
|
private:
|
||||||
void reload_search_path();
|
void reload_search_path();
|
||||||
|
|
||||||
|
DSearchPath _default_value;
|
||||||
DSearchPath _prefix, _postfix;
|
DSearchPath _prefix, _postfix;
|
||||||
|
|
||||||
AtomicAdjust::Integer _local_modified;
|
AtomicAdjust::Integer _local_modified;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user