26 DSearchPath::Results::
33 DSearchPath::Results::
42 void DSearchPath::Results::
50 DSearchPath::Results::
75 assert(n < _files.size());
84 _files.push_back(file);
90 void DSearchPath::Results::
91 output(ostream &out)
const {
93 if (!_files.empty()) {
94 Files::const_iterator fi = _files.begin();
97 while (fi != _files.end()) {
108 void DSearchPath::Results::
109 write(ostream &out,
int indent_level)
const {
110 Files::const_iterator fi;
111 for (fi = _files.begin(); fi != _files.end(); ++fi) {
112 for (
int i = 0; i < indent_level; ++i) {
115 out << (*fi) <<
"\n";
123 DSearchPath(
const string &path,
const string &separator) {
131 DSearchPath(
const Filename &directory) {
140 _directories.clear();
148 _directories.push_back(directory);
156 _directories.insert(_directories.begin(), directory);
164 append_path(
const string &path,
const string &separator) {
165 string pathsep = separator;
166 if (pathsep.empty()) {
167 pathsep = DEFAULT_PATHSEP;
170 if (pathsep.empty()) {
175 while (p < path.length()) {
176 size_t q = path.find_first_of(pathsep, p);
177 if (q == string::npos) {
195 std::copy(path._directories.begin(), path._directories.end(),
196 std::back_inserter(_directories));
205 if (!path._directories.empty()) {
207 std::copy(_directories.begin(), _directories.end(),
208 std::back_inserter(new_directories));
209 _directories.swap(new_directories);
218 return _directories.empty();
226 return _directories.size();
234 assert(n < _directories.size());
235 return _directories[n];
246 if (_directories.empty()) {
254 Directories::const_iterator di;
255 for (di = _directories.begin(); di != _directories.end(); ++di) {
286 size_t num_added = 0;
289 if (_directories.empty()) {
297 Directories::const_iterator di;
298 for (di = _directories.begin(); di != _directories.end(); ++di) {
323 output(ostream &out,
const string &separator)
const {
324 string pathsep = separator;
325 if (pathsep.empty()) {
326 pathsep = DEFAULT_PATHSEP;
327 if (!pathsep.empty()) {
328 pathsep = pathsep[0];
332 if (!_directories.empty()) {
333 Directories::const_iterator di = _directories.begin();
336 while (di != _directories.end()) {
337 out << pathsep << (*di);
347 write(ostream &out,
int indent_level)
const {
348 Directories::const_iterator di;
349 for (di = _directories.begin(); di != _directories.end(); ++di) {
350 for (
int i = 0; i < indent_level; ++i) {
353 out << (*di) <<
"\n";
void clear()
Removes all the files from the list.
const Filename & get_file(size_t n) const
Returns the nth file on the result list.
void add_file(const Filename &file)
Adds a new file to the result list.
size_t get_num_files() const
Returns the number of files on the result list.
This class stores a list of directories that can be searched, in order, to locate a particular file.
Filename find_file(const Filename &filename) const
Searches all the directories in the search list for the indicated file, in order.
bool is_empty() const
Returns true if the search list is empty, false otherwise.
void append_path(const std::string &path, const std::string &separator=std::string())
Adds all of the directories listed in the search path to the end of the search list.
get_num_directories
Returns the number of directories on the search list.
size_t find_all_files(const Filename &filename, Results &results) const
Searches all the directories in the search list for the indicated file, in order.
void prepend_path(const DSearchPath &path)
Adds all of the directories listed in the search path to the beginning of the search list.
void prepend_directory(const Filename &directory)
Adds a new directory to the front of the search list.
void clear()
Removes all the directories from the search list.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
get_directory
Returns the nth directory on the search list.
The name of a file, such as a texture file or an Egg file.
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
bool is_local() const
Returns true if the filename is local, e.g.
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.