|
@@ -85,12 +85,22 @@ get_num_files() const {
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
// Description: Returns the nth file on the result list.
|
|
// Description: Returns the nth file on the result list.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-Filename DSearchPath::Results::
|
|
|
|
|
|
|
+const Filename &DSearchPath::Results::
|
|
|
get_file(int n) const {
|
|
get_file(int n) const {
|
|
|
assert(n >= 0 && n < (int)_files.size());
|
|
assert(n >= 0 && n < (int)_files.size());
|
|
|
return _files[n];
|
|
return _files[n];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: DSearchPath::Results::add_file
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Adds a new file to the result list.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+void DSearchPath::Results::
|
|
|
|
|
+add_file(const Filename &file) {
|
|
|
|
|
+ _files.push_back(file);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DSearchPath::Default Constructor
|
|
// Function: DSearchPath::Default Constructor
|
|
|
// Access: Public
|
|
// Access: Public
|
|
@@ -246,7 +256,7 @@ get_num_directories() const {
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
// Description: Returns the nth directory on the search list.
|
|
// Description: Returns the nth directory on the search list.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-Filename DSearchPath::
|
|
|
|
|
|
|
+const Filename &DSearchPath::
|
|
|
get_directory(int n) const {
|
|
get_directory(int n) const {
|
|
|
assert(n >= 0 && n < (int)_directories.size());
|
|
assert(n >= 0 && n < (int)_directories.size());
|
|
|
return _directories[n];
|
|
return _directories[n];
|
|
@@ -262,11 +272,13 @@ get_directory(int n) const {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
Filename DSearchPath::
|
|
Filename DSearchPath::
|
|
|
find_file(const Filename &filename) const {
|
|
find_file(const Filename &filename) const {
|
|
|
- Directories::const_iterator di;
|
|
|
|
|
- for (di = _directories.begin(); di != _directories.end(); ++di) {
|
|
|
|
|
- Filename match((*di), filename);
|
|
|
|
|
- if (match.exists()) {
|
|
|
|
|
- return match;
|
|
|
|
|
|
|
+ if (filename.is_local()) {
|
|
|
|
|
+ Directories::const_iterator di;
|
|
|
|
|
+ for (di = _directories.begin(); di != _directories.end(); ++di) {
|
|
|
|
|
+ Filename match((*di), filename);
|
|
|
|
|
+ if (match.exists()) {
|
|
|
|
|
+ return match;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -280,21 +292,28 @@ find_file(const Filename &filename) const {
|
|
|
// the indicated file, in order. Fills up the results
|
|
// the indicated file, in order. Fills up the results
|
|
|
// list with *all* of the matching filenames found, if
|
|
// list with *all* of the matching filenames found, if
|
|
|
// any. Returns the number of matches found.
|
|
// any. Returns the number of matches found.
|
|
|
|
|
+//
|
|
|
|
|
+// It is the responsibility of the the caller to clear
|
|
|
|
|
+// the results list first; otherwise, the newly-found
|
|
|
|
|
+// files will be appended to the list.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
int DSearchPath::
|
|
int DSearchPath::
|
|
|
find_all_files(const Filename &filename,
|
|
find_all_files(const Filename &filename,
|
|
|
DSearchPath::Results &results) const {
|
|
DSearchPath::Results &results) const {
|
|
|
- results._files.clear();
|
|
|
|
|
-
|
|
|
|
|
- Directories::const_iterator di;
|
|
|
|
|
- for (di = _directories.begin(); di != _directories.end(); ++di) {
|
|
|
|
|
- Filename match((*di), filename);
|
|
|
|
|
- if (match.exists()) {
|
|
|
|
|
- results._files.push_back(match);
|
|
|
|
|
|
|
+ int num_added = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (filename.is_local()) {
|
|
|
|
|
+ Directories::const_iterator di;
|
|
|
|
|
+ for (di = _directories.begin(); di != _directories.end(); ++di) {
|
|
|
|
|
+ Filename match((*di), filename);
|
|
|
|
|
+ if (match.exists()) {
|
|
|
|
|
+ results.add_file(match);
|
|
|
|
|
+ num_added++;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return results._files.size();
|
|
|
|
|
|
|
+ return num_added;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|