00001 // Filename: configVariableSearchPath.cxx 00002 // Created by: drose (21Oct04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "configVariableSearchPath.h" 00016 #include "executionEnvironment.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: ConfigVariableSearchPath::reload_search_path 00020 // Access: Private 00021 // Description: Recopies the config variable into the search path for 00022 // returning its value. 00023 //////////////////////////////////////////////////////////////////// 00024 void ConfigVariableSearchPath:: 00025 reload_search_path() { 00026 nassertv(_core != (ConfigVariableCore *)NULL); 00027 mark_cache_valid(_local_modified); 00028 _cache.clear(); 00029 00030 _cache.append_path(_prefix); 00031 int num_unique_references = _core->get_num_unique_references(); 00032 for (int i = 0; i < num_unique_references; i++) { 00033 const ConfigDeclaration *decl = _core->get_unique_reference(i); 00034 const ConfigPage *page = decl->get_page(); 00035 00036 Filename page_filename(page->get_name()); 00037 Filename page_dirname = page_filename.get_dirname(); 00038 ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); 00039 string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); 00040 ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); 00041 if (!expanded.empty()) { 00042 Filename dir = Filename::from_os_specific(expanded); 00043 dir.make_true_case(); 00044 _cache.append_directory(dir); 00045 } 00046 } 00047 00048 if (_prefix.is_empty() && _postfix.is_empty() && 00049 num_unique_references == 0) { 00050 // An empty search path implicitly has the default value. 00051 _cache = _default_value; 00052 } 00053 00054 _cache.append_path(_postfix); 00055 }