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 void reduce_file_separators (cmt_string& text);
00057 static char path_separator ();
00058 static char command_separator ();
00059 static const cmt_string& ev_open ();
00060 static const cmt_string& ev_close ();
00061 static bool create_symlink (const cmt_string& oldname,
00062 const cmt_string& newname);
00063 static bool remove_file (const cmt_string& name);
00064 static bool remove_directory (const cmt_string& name);
00065 static bool mkdir (const cmt_string& name);
00066 static void scan_dir (const cmt_string& dir_name,
00067 cmt_string_vector& list);
00068 static void scan_dir (const cmt_string& dir_name,
00069 const cmt_regexp& expression,
00070 cmt_string_vector& list);
00071 static cmt_string_vector& scan_dir (const cmt_string& dir_name);
00072 static const cmt_string& get_cmt_root ();
00073 static void get_cmt_version (cmt_string& version);
00074 static cmt_string get_cmt_config ();
00075 static cmt_string get_cmt_site ();
00076 static void get_uname (cmt_string& uname);
00077 static void get_hosttype (cmt_string& hosttype);
00078 static cmt_string get_temporary_name ();
00079
00080 static cmt_string get_home_package ();
00081 static bool is_home_package (const cmt_string& name,
00082 const cmt_string& version);
00083
00084 static cmt_string get_user_context_package ();
00085 static bool is_user_context_package (const cmt_string& name,
00086 const cmt_string& version);
00087
00088 static bool testenv (const cmt_string& name);
00089 static cmt_string getenv (const cmt_string& name);
00090 static void add_cmt_path (const cmt_string& path,
00091 const cmt_string& path_source,
00092 cmt_string_vector& paths,
00093 cmt_string_vector& path_pwds,
00094 cmt_string_vector& path_sources);
00095 static void get_cmt_paths (cmt_string_vector& paths,
00096 cmt_string_vector& path_pwds,
00097 cmt_string_vector& path_sources,
00098 const cmt_string& init_text = "");
00099 static int execute (const cmt_string& command);
00100 static int execute (const cmt_string& command, cmt_string& output);
00101 static bool is_package_directory (const cmt_string& name);
00102 static bool is_version_directory (const cmt_string& name);
00103 static bool is_version_directory (const cmt_string& name, int& v, int& r, int& p);
00104 static void split (const cmt_string& text,
00105 const cmt_string& separators,
00106 cmt_string_vector& strings);
00107
00108 static void compress_path (const cmt_string& dir, cmt_string& new_dir);
00109 static void compress_path (cmt_string& dir);
00110
00111 static cmt_string now ();
00112 static cmt_string user ();
00113
00114 static void get_cvsroot (cmt_string& cvsroot);
00115
00116 };
00117
00118 #endif