Panda3D
Loading...
Searching...
No Matches
cvsSourceTree.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cvsSourceTree.h
10 * @author drose
11 * @date 2000-10-31
12 */
13
14#ifndef CVSSOURCETREE_H
15#define CVSSOURCETREE_H
16
17#include "pandatoolbase.h"
18
19#include "pvector.h"
20#include "pmap.h"
21#include "filename.h"
22
24
25/**
26 * This represents the root of the tree of source directory files.
27 *
28 * The tree is maintained in a case-insensitive manner, even on a non-Windows
29 * system, since you might want to eventually check out the CVS tree onto a
30 * Windows system--and if you do, you'll be sad if there are case conflicts
31 * within the tree. So we make an effort to ensure this doesn't happen by
32 * treating two files with a different case as the same file.
33 */
35public:
38
39 void set_root(const Filename &root_path);
40 bool scan(const Filename &key_filename);
41
44 CVSSourceDirectory *find_relpath(const std::string &relpath);
45 CVSSourceDirectory *find_dirname(const std::string &dirname);
46
47 // This nested class represents the selection of a particular directory in
48 // which to place a given file, given its basename. The basename of the
49 // file is returned as part of the answer, because it might have changed in
50 // case from the original basename (in order to match the case of an
51 // existing file in the selected directory).
52 class FilePath {
53 public:
54 FilePath();
55 FilePath(CVSSourceDirectory *dir, const std::string &basename);
56 bool is_valid() const;
57 Filename get_path() const;
58 Filename get_fullpath() const;
59 Filename get_rel_from(const CVSSourceDirectory *other) const;
60
62 std::string _basename;
63 };
64
65 FilePath choose_directory(const std::string &basename,
66 CVSSourceDirectory *suggested_dir,
67 bool force, bool interactive);
68
71
72 static bool temp_chdir(const Filename &path);
73 static void restore_cwd();
74
75public:
76 void add_file(const std::string &basename, CVSSourceDirectory *dir);
77
78private:
80
82 prompt_user(const std::string &basename, CVSSourceDirectory *suggested_dir,
83 const FilePaths &paths, bool force, bool interactive);
84
85 FilePath ask_existing(const std::string &filename, const FilePath &path);
86 FilePath ask_existing(const std::string &filename, const FilePaths &paths,
87 CVSSourceDirectory *suggested_dir);
88 FilePath ask_new(const std::string &filename, CVSSourceDirectory *dir);
89 FilePath ask_any(const std::string &filename, const FilePaths &paths);
90
91 std::string prompt(const std::string &message);
92
93 static Filename get_actual_fullpath(const Filename &path);
94 static Filename get_start_fullpath();
95
96private:
97 Filename _path;
98 CVSSourceDirectory *_root;
99
101 Basenames _basenames;
102
103 static bool _got_start_fullpath;
104 static Filename _start_fullpath;
105 bool _got_root_fullpath;
106 Filename _root_fullpath;
107};
108
109#endif
This represents one particular directory in the hierarchy of source directory files.
Filename get_path() const
Returns the relative path to this file from the root of the source tree.
FilePath()
Creates an invalid FilePath specification.
Filename get_rel_from(const CVSSourceDirectory *other) const
Returns the relative path to this file as seen from the indicated source directory.
bool is_valid() const
Returns true if this FilePath represents a valid file, or false if it represents an error return.
Filename get_fullpath() const
Returns the full path to this file.
This represents the root of the tree of source directory files.
CVSSourceDirectory * get_root() const
Returns the root directory of the hierarchy.
Filename get_root_fullpath()
Returns the full path from the root to the top of the source hierarchy.
void add_file(const std::string &basename, CVSSourceDirectory *dir)
Adds a new file to the set of known files.
void set_root(const Filename &root_path)
Sets the root of the source directory.
FilePath choose_directory(const std::string &basename, CVSSourceDirectory *suggested_dir, bool force, bool interactive)
Determines where an externally referenced model file of the indicated name should go.
Filename get_root_dirname() const
Returns the local directory name of the root of the tree.
CVSSourceDirectory * find_relpath(const std::string &relpath)
Returns the source directory that corresponds to the given relative path from the root,...
static bool temp_chdir(const Filename &path)
Temporarily changes the current directory to the named path.
CVSSourceDirectory * find_directory(const Filename &path)
Returns the source directory that corresponds to the given path, or NULL if there is no such director...
static void restore_cwd()
Restores the current directory after changing it from temp_chdir().
bool scan(const Filename &key_filename)
Scans the complete source directory starting at the indicated pathname.
CVSSourceDirectory * find_dirname(const std::string &dirname)
Returns the source directory that corresponds to the given local directory name, or NULL if there is ...
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.