00001 #ifndef __cmt_system_h__ 00002 #define __cmt_system_h__ 00003 00004 #include "cmt_std.h" 00005 #include "cmt_string.h" 00006 #include "cmt_vector.h" 00007 #include "cmt_regexp.h" 00008 00009 class CmtSystem 00010 { 00011 public: 00012 typedef cmt_vector<cmt_string> cmt_string_vector; 00013 00014 static cmt_string pwd (); 00015 static bool cd (const cmt_string& dir); 00016 00017 static void basename (const cmt_string& file_name, cmt_string& result); 00018 static void basename (const cmt_string& file_name, 00019 const cmt_string& suffix, 00020 cmt_string& result); 00021 00022 static void dirname (const cmt_string& file_name, cmt_string& result); 00023 00024 static void name (const cmt_string& file, cmt_string& result); 00025 00026 static void get_suffix (const cmt_string& file, cmt_string& result); 00027 static void get_dot_suffix (const cmt_string& file, cmt_string& result); 00028 static bool has_prefix (const cmt_string& name); 00029 static bool absolute_path (const cmt_string& name); 00030 static bool has_device (const cmt_string& name); 00031 00032 static cmt_string current_branch (); 00033 00037 static bool test_directory (const cmt_string& name); 00041 static bool test_file (const cmt_string& name); 00045 static bool compare_files (const cmt_string& name1, 00046 const cmt_string& name2); 00052 static bool compare_and_update_files (const cmt_string& name1, 00053 const cmt_string& name2); 00054 static int file_size (const cmt_string& name); 00055 static char file_separator (); 00056 static char path_separator (); 00057 static char command_separator (); 00058 static const cmt_string& ev_open (); 00059 static const cmt_string& ev_close (); 00060 static bool create_symlink (const cmt_string& oldname, 00061 const cmt_string& newname); 00062 static bool remove_file (const cmt_string& name); 00063 static bool remove_directory (const cmt_string& name); 00064 static bool mkdir (const cmt_string& name); 00065 static void scan_dir (const cmt_string& dir_name, 00066 cmt_string_vector& list); 00067 static void scan_dir (const cmt_string& dir_name, 00068 const cmt_regexp& expression, 00069 cmt_string_vector& list); 00070 static cmt_string_vector& scan_dir (const cmt_string& dir_name); 00071 static const cmt_string& get_cmt_root (); 00072 static void get_cmt_version (cmt_string& version); 00073 static cmt_string get_cmt_config (); 00074 static cmt_string get_cmt_site (); 00075 static void get_uname (cmt_string& uname); 00076 static void get_hosttype (cmt_string& hosttype); 00077 static cmt_string get_temporary_name (); 00078 00079 static cmt_string get_home_package (); 00080 static bool is_home_package (const cmt_string& name, 00081 const cmt_string& version); 00082 00083 static cmt_string get_user_context_package (); 00084 static bool is_user_context_package (const cmt_string& name, 00085 const cmt_string& version); 00086 00087 static bool testenv (const cmt_string& name); 00088 static cmt_string getenv (const cmt_string& name); 00089 static void add_cmt_path (const cmt_string& path, 00090 const cmt_string& path_source, 00091 cmt_string_vector& paths, 00092 cmt_string_vector& path_pwds, 00093 cmt_string_vector& path_sources); 00094 static void get_cmt_paths (cmt_string_vector& paths, 00095 cmt_string_vector& path_pwds, 00096 cmt_string_vector& path_sources, 00097 const cmt_string& init_text = ""); 00098 static int execute (const cmt_string& command); 00099 static int execute (const cmt_string& command, cmt_string& output); 00100 static bool is_package_directory (const cmt_string& name); 00101 static bool is_version_directory (const cmt_string& name); 00102 static bool is_version_directory (const cmt_string& name, int& v, int& r, int& p); 00103 static void split (const cmt_string& text, 00104 const cmt_string& separators, 00105 cmt_string_vector& strings); 00106 00107 static void compress_path (const cmt_string& dir, cmt_string& new_dir); 00108 static void compress_path (cmt_string& dir); 00109 00110 static cmt_string now (); 00111 static cmt_string user (); 00112 00113 static void get_cvsroot (cmt_string& cvsroot); 00114 00115 }; 00116 00117 #endif