00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CVSSOURCETREE_H
00016 #define CVSSOURCETREE_H
00017
00018 #include "pandatoolbase.h"
00019
00020 #include "pvector.h"
00021 #include "pmap.h"
00022 #include "filename.h"
00023
00024 class CVSSourceDirectory;
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class CVSSourceTree {
00040 public:
00041 CVSSourceTree();
00042 ~CVSSourceTree();
00043
00044 void set_root(const Filename &root_path);
00045 bool scan(const Filename &key_filename);
00046
00047 CVSSourceDirectory *get_root() const;
00048 CVSSourceDirectory *find_directory(const Filename &path);
00049 CVSSourceDirectory *find_relpath(const string &relpath);
00050 CVSSourceDirectory *find_dirname(const string &dirname);
00051
00052
00053
00054
00055
00056
00057
00058 class FilePath {
00059 public:
00060 FilePath();
00061 FilePath(CVSSourceDirectory *dir, const string &basename);
00062 bool is_valid() const;
00063 Filename get_path() const;
00064 Filename get_fullpath() const;
00065 Filename get_rel_from(const CVSSourceDirectory *other) const;
00066
00067 CVSSourceDirectory *_dir;
00068 string _basename;
00069 };
00070
00071 FilePath choose_directory(const string &basename,
00072 CVSSourceDirectory *suggested_dir,
00073 bool force, bool interactive);
00074
00075 Filename get_root_fullpath();
00076 Filename get_root_dirname() const;
00077
00078 static bool temp_chdir(const Filename &path);
00079 static void restore_cwd();
00080
00081 public:
00082 void add_file(const string &basename, CVSSourceDirectory *dir);
00083
00084 private:
00085 typedef pvector<FilePath> FilePaths;
00086
00087 FilePath
00088 prompt_user(const string &basename, CVSSourceDirectory *suggested_dir,
00089 const FilePaths &paths, bool force, bool interactive);
00090
00091 FilePath ask_existing(const string &filename, const FilePath &path);
00092 FilePath ask_existing(const string &filename, const FilePaths &paths,
00093 CVSSourceDirectory *suggested_dir);
00094 FilePath ask_new(const string &filename, CVSSourceDirectory *dir);
00095 FilePath ask_any(const string &filename, const FilePaths &paths);
00096
00097 string prompt(const string &message);
00098
00099 static Filename get_actual_fullpath(const Filename &path);
00100 static Filename get_start_fullpath();
00101
00102 private:
00103 Filename _path;
00104 CVSSourceDirectory *_root;
00105
00106 typedef pmap<string, FilePaths> Basenames;
00107 Basenames _basenames;
00108
00109 static bool _got_start_fullpath;
00110 static Filename _start_fullpath;
00111 bool _got_root_fullpath;
00112 Filename _root_fullpath;
00113 };
00114
00115 #endif