Panda3D
dSearchPath.I
1 // Filename: dSearchPath.I
2 // Created by: drose (01Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: DSearchPath::Results::operator []
18 // Access: Published
19 // Description: Returns the nth filename in the set. This method is
20 // defined to make the Results object appear to be a
21 // list in Python.
22 ////////////////////////////////////////////////////////////////////
24 operator [] (int n) const {
25  return get_file(n);
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: DSearchPath::Results::size
30 // Access: Published
31 // Description: Returns the num of filenames in the set. This method
32 // is defined to make the Results object appear to be a
33 // list in Python.
34 ////////////////////////////////////////////////////////////////////
35 INLINE int DSearchPath::Results::
36 size() const {
37  return get_num_files();
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: DSearchPath::find_all_files
42 // Access: Published
43 // Description: This variant of find_all_files() returns the new
44 // Results object, instead of filling on in on the
45 // parameter list. This is a little more convenient to
46 // call from Python.
47 ////////////////////////////////////////////////////////////////////
49 find_all_files(const Filename &filename) const {
50  Results results;
51  find_all_files(filename, results);
52  return results;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: DSearchPath::search_path
57 // Access: Published, Static
58 // Description: A quick-and-easy way to search a searchpath for a
59 // file when you don't feel like building or keeping
60 // around a DSearchPath object. This simply
61 // constructs a temporary DSearchPath based on the
62 // indicated path string, and searches that.
63 ////////////////////////////////////////////////////////////////////
65 search_path(const Filename &filename, const string &path,
66  const string &separator) {
67  DSearchPath search(path, separator);
68  return search.find_file(filename);
69 }
int get_num_files() const
Returns the number of files on the result list.
Definition: dSearchPath.cxx:76
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
int size() const
Returns the num of filenames in the set.
Definition: dSearchPath.I:36
static Filename search_path(const Filename &filename, const string &path, const string &separator=string())
A quick-and-easy way to search a searchpath for a file when you don't feel like building or keeping a...
Definition: dSearchPath.I:65
int find_all_files(const Filename &filename, Results &results) const
Searches all the directories in the search list for the indicated file, in order. ...
This class stores a list of directories that can be searched, in order, to locate a particular file...
Definition: dSearchPath.h:32
const Filename & get_file(int n) const
Returns the nth file on the result list.
Definition: dSearchPath.cxx:86
Filename operator[](int n) const
Returns the nth filename in the set.
Definition: dSearchPath.I:24
Filename find_file(const Filename &filename) const
Searches all the directories in the search list for the indicated file, in order. ...