Go to the documentation of this file.
27 const string &dirname) :
32 if (_parent ==
nullptr) {
35 _depth = _parent->_depth + 1;
43 ~CVSSourceDirectory() {
44 Children::iterator ci;
45 for (ci = _children.begin(); ci != _children.end(); ++ci) {
63 if (_parent ==
nullptr) {
75 if (_parent ==
nullptr) {
94 string prefix, postfix;
95 while (a->_depth > b->_depth) {
98 nassertr(a !=
nullptr,
string());
101 while (b->_depth > a->_depth) {
102 postfix = b->_dirname +
"/" + postfix;
104 nassertr(b !=
nullptr,
string());
109 postfix = b->_dirname +
"/" + postfix;
112 nassertr(a !=
nullptr,
string());
113 nassertr(b !=
nullptr,
string());
116 string result = prefix + postfix;
117 nassertr(!result.empty(),
string());
118 return result.substr(0, result.length() - 1);
126 return _children.size();
134 nassertr(n >= 0 && n < (
int)_children.size(),
nullptr);
144 if (relpath.empty()) {
148 size_t slash = relpath.find(
'/');
149 string first = relpath.substr(0, slash);
151 if (slash != string::npos) {
152 rest = relpath.substr(slash + 1);
155 if (first.empty() || first ==
".") {
158 }
else if (first ==
"..") {
159 if (_parent !=
nullptr) {
167 Children::const_iterator ci;
168 for (ci = _children.begin(); ci != _children.end(); ++ci) {
169 if (cmp_nocase((*ci)->get_dirname(), first) == 0) {
184 if (cmp_nocase(dirname, _dirname) == 0) {
188 Children::const_iterator ci;
189 for (ci = _children.begin(); ci != _children.end(); ++ci) {
191 if (result !=
nullptr) {
207 vector_string contents;
209 nout <<
"Unable to scan directory " << directory <<
"\n";
213 vector_string::const_iterator fi;
214 for (fi = contents.begin(); fi != contents.end(); ++fi) {
215 const string &basename = (*fi);
218 Filename next_path(directory, basename);
219 Filename key(next_path, key_filename);
224 _children.push_back(subdir);
226 if (!subdir->
scan(next_path, key_filename)) {
CVSSourceDirectory * get_child(int n) const
Returns the nth subdirectory below this directory.
bool scan_directory(vector_string &contents) const
Attempts to open the named filename as if it were a directory and looks for the non-hidden files with...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
Filename get_rel_to(const CVSSourceDirectory *other) const
Returns the relative path to the other directory from this one.
bool scan(const Filename &directory, const std::string &key_filename)
Recursively scans the contents of the source directory.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Filename get_path() const
Returns the relative pathname to this particular directory, as seen from the root of the tree.
Filename get_fullpath() const
Returns the full pathname to this particular directory.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_children() const
Returns the number of subdirectories below this directory.
CVSSourceDirectory * find_dirname(const std::string &dirname)
Returns the source directory that corresponds to the given local directory name, or NULL if there is ...
This represents one particular directory in the hierarchy of source directory files.
std::string get_dirname() const
Returns the local name of this particular directory.
Filename get_root_fullpath()
Returns the full path from the root to the top of the source hierarchy.
This represents the root of the tree of source directory files.
void add_file(const std::string &basename, CVSSourceDirectory *dir)
Adds a new file to the set of known files.
The name of a file, such as a texture file or an Egg file.
CVSSourceDirectory * find_relpath(const std::string &relpath)
Returns the source directory that corresponds to the given relative path from this directory,...