mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
// Filename: dSearchPath.h
|
|
// Created by: drose (01Jul00)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// PANDA 3D SOFTWARE
|
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
|
//
|
|
// All use of this software is subject to the terms of the Panda 3d
|
|
// Software license. You should have received a copy of this license
|
|
// along with this source code; you will also find a current copy of
|
|
// the license at http://www.panda3d.org/license.txt .
|
|
//
|
|
// To contact the maintainers of this program write to
|
|
// panda3d@yahoogroups.com .
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef PANDASEARCHPATH_H
|
|
#define PANDASEARCHPATH_H
|
|
|
|
#include <dtoolbase.h>
|
|
|
|
#include "filename.h"
|
|
|
|
#include <vector>
|
|
|
|
extern EXPCL_DTOOL const string standard_delimiters;
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
// Class : DSearchPath
|
|
// Description : This class stores a list of directories that can be
|
|
// searched, in order, to locate a particular file. It
|
|
// is normally constructed by passing it a traditional
|
|
// searchpath-style string, e.g. a list of directory
|
|
// names delimited by spaces or colons, but it can also
|
|
// be built up explicitly.
|
|
////////////////////////////////////////////////////////////////////
|
|
class EXPCL_DTOOL DSearchPath {
|
|
public:
|
|
class EXPCL_DTOOL Results {
|
|
PUBLISHED:
|
|
Results();
|
|
Results(const Results ©);
|
|
void operator = (const Results ©);
|
|
~Results();
|
|
|
|
void clear();
|
|
int get_num_files() const;
|
|
Filename get_file(int n) const;
|
|
|
|
private:
|
|
typedef vector<Filename> Files;
|
|
Files _files;
|
|
friend class DSearchPath;
|
|
};
|
|
|
|
PUBLISHED:
|
|
DSearchPath();
|
|
DSearchPath(const string &path, const string &delimiters = standard_delimiters);
|
|
DSearchPath(const DSearchPath ©);
|
|
void operator = (const DSearchPath ©);
|
|
~DSearchPath();
|
|
|
|
void clear();
|
|
void append_directory(const Filename &directory);
|
|
void prepend_directory(const Filename &directory);
|
|
void append_path(const string &path,
|
|
const string &delimiters = standard_delimiters);
|
|
void append_path(const DSearchPath &path);
|
|
void prepend_path(const DSearchPath &path);
|
|
|
|
bool is_empty() const;
|
|
int get_num_directories() const;
|
|
Filename get_directory(int n) const;
|
|
|
|
Filename find_file(const Filename &filename) const;
|
|
int find_all_files(const Filename &filename, Results &results) const;
|
|
|
|
INLINE static Filename
|
|
search_path(const Filename &filename, const string &path,
|
|
const string &delimiters = standard_delimiters);
|
|
|
|
void output(ostream &out, const string &separator = ":") const;
|
|
void write(ostream &out, int indent_level = 0) const;
|
|
|
|
private:
|
|
typedef vector<Filename> Directories;
|
|
Directories _directories;
|
|
};
|
|
|
|
INLINE ostream &operator << (ostream &out, const DSearchPath &sp) {
|
|
sp.output(out);
|
|
return out;
|
|
}
|
|
|
|
#include "dSearchPath.I"
|
|
|
|
#endif
|