00001 // Filename: dSearchPath.I 00002 // Created by: drose (01Jul00) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: DSearchPath::Results::operator [] 00018 // Access: Published 00019 // Description: Returns the nth filename in the set. This method is 00020 // defined to make the Results object appear to be a 00021 // list in Python. 00022 //////////////////////////////////////////////////////////////////// 00023 INLINE Filename DSearchPath::Results:: 00024 operator [] (int n) const { 00025 return get_file(n); 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: DSearchPath::Results::size 00030 // Access: Published 00031 // Description: Returns the num of filenames in the set. This method 00032 // is defined to make the Results object appear to be a 00033 // list in Python. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE int DSearchPath::Results:: 00036 size() const { 00037 return get_num_files(); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: DSearchPath::find_all_files 00042 // Access: Published 00043 // Description: This variant of find_all_files() returns the new 00044 // Results object, instead of filling on in on the 00045 // parameter list. This is a little more convenient to 00046 // call from Python. 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE DSearchPath::Results DSearchPath:: 00049 find_all_files(const Filename &filename) const { 00050 Results results; 00051 find_all_files(filename, results); 00052 return results; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: DSearchPath::search_path 00057 // Access: Published, Static 00058 // Description: A quick-and-easy way to search a searchpath for a 00059 // file when you don't feel like building or keeping 00060 // around a DSearchPath object. This simply 00061 // constructs a temporary DSearchPath based on the 00062 // indicated path string, and searches that. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE Filename DSearchPath:: 00065 search_path(const Filename &filename, const string &path, 00066 const string &separator) { 00067 DSearchPath search(path, separator); 00068 return search.find_file(filename); 00069 }