Panda3D
configVariableSearchPath.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file configVariableSearchPath.cxx
10  * @author drose
11  * @date 2004-10-21
12  */
13 
15 #include "executionEnvironment.h"
16 
17 /**
18  * Recopies the config variable into the search path for returning its value.
19  */
20 void ConfigVariableSearchPath::
21 reload_search_path() {
22  nassertv(_core != nullptr);
23  mark_cache_valid(_local_modified);
24  _cache.clear();
25 
26  _cache.append_path(_prefix);
27  size_t num_unique_references = _core->get_num_unique_references();
28  for (size_t i = 0; i < num_unique_references; i++) {
29  const ConfigDeclaration *decl = _core->get_unique_reference(i);
30 
31  Filename fn = decl->get_filename_value();
32  if (!fn.empty()) {
33  _cache.append_directory(std::move(fn));
34  }
35  }
36 
37  if (_prefix.is_empty() && _postfix.is_empty() &&
38  num_unique_references == 0) {
39  // An empty search path implicitly has the default value.
40  _cache = _default_value;
41  }
42 
43  _cache.append_path(_postfix);
44 }
void clear()
Removes all the directories from the search list.
bool is_empty() const
Returns true if the search list is empty, false otherwise.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
Filename get_filename_value() const
Interprets the string value as a filename and returns it, with any variables expanded.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single declaration of a config variable, typically defined as one line in a .prc file,...