mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
change model_path logic
This commit is contained in:
parent
39e03a8d0e
commit
a4f7ec2980
@ -85,12 +85,22 @@ get_num_files() const {
|
||||
// Access: Public
|
||||
// Description: Returns the nth file on the result list.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename DSearchPath::Results::
|
||||
const Filename &DSearchPath::Results::
|
||||
get_file(int n) const {
|
||||
assert(n >= 0 && n < (int)_files.size());
|
||||
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
|
||||
// Access: Public
|
||||
@ -246,7 +256,7 @@ get_num_directories() const {
|
||||
// Access: Public
|
||||
// Description: Returns the nth directory on the search list.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename DSearchPath::
|
||||
const Filename &DSearchPath::
|
||||
get_directory(int n) const {
|
||||
assert(n >= 0 && n < (int)_directories.size());
|
||||
return _directories[n];
|
||||
@ -262,11 +272,13 @@ get_directory(int n) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename DSearchPath::
|
||||
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
|
||||
// list with *all* of the matching filenames found, if
|
||||
// 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::
|
||||
find_all_files(const Filename &filename,
|
||||
DSearchPath::Results &results) const {
|
||||
results._files.clear();
|
||||
int num_added = 0;
|
||||
|
||||
Directories::const_iterator di;
|
||||
for (di = _directories.begin(); di != _directories.end(); ++di) {
|
||||
Filename match((*di), filename);
|
||||
if (match.exists()) {
|
||||
results._files.push_back(match);
|
||||
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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -19,11 +19,10 @@
|
||||
#ifndef PANDASEARCHPATH_H
|
||||
#define PANDASEARCHPATH_H
|
||||
|
||||
#include <dtoolbase.h>
|
||||
#include "dtoolbase.h"
|
||||
|
||||
#include "filename.h"
|
||||
|
||||
#include <vector>
|
||||
#include "pvector.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Class : DSearchPath
|
||||
@ -45,12 +44,14 @@ public:
|
||||
|
||||
void clear();
|
||||
int get_num_files() const;
|
||||
Filename get_file(int n) const;
|
||||
const Filename &get_file(int n) const;
|
||||
|
||||
public:
|
||||
void add_file(const Filename &file);
|
||||
|
||||
private:
|
||||
typedef vector<Filename> Files;
|
||||
typedef pvector<Filename> Files;
|
||||
Files _files;
|
||||
friend class DSearchPath;
|
||||
};
|
||||
|
||||
PUBLISHED:
|
||||
@ -70,7 +71,7 @@ PUBLISHED:
|
||||
|
||||
bool is_empty() const;
|
||||
int get_num_directories() const;
|
||||
Filename get_directory(int n) const;
|
||||
const Filename &get_directory(int n) const;
|
||||
|
||||
Filename find_file(const Filename &filename) const;
|
||||
int find_all_files(const Filename &filename, Results &results) const;
|
||||
@ -83,7 +84,7 @@ PUBLISHED:
|
||||
void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
private:
|
||||
typedef vector<Filename> Directories;
|
||||
typedef pvector<Filename> Directories;
|
||||
Directories _directories;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user