source: CMT/v1r19p20061114/source/cmt_system.h

Last change on this file was 201, checked in by garonne, 18 years ago

add the touch function during checkout operation

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// See the complete license in cmt_license.txt "http://www.cecill.info".
5//-----------------------------------------------------------
6
7#ifndef __cmt_system_h__
8#define __cmt_system_h__
9
10#include "cmt_std.h"
11#include "cmt_string.h"
12#include "cmt_vector.h"
13#include "cmt_regexp.h"
14
15class Project;
16
17class IProjectFactory
18{
19public:
20  virtual void reset () = 0;
21  virtual Project* create_project (const cmt_string& name,
22                                   const cmt_string& path,
23                                   const cmt_string& path_source,
24                                   Project* parent) = 0;
25};
26
27class CmtSystem
28{
29public:
30  typedef cmt_vector<cmt_string> cmt_string_vector;
31
32  static cmt_string pwd ();
33  static bool cd (const cmt_string& dir);
34
35  static void basename (const cmt_string& file_name, cmt_string& result);
36  static void basename (const cmt_string& file_name,
37                        const cmt_string& suffix,
38                        cmt_string& result);
39
40  // Resolve symbolic links in a path.
41  static bool realpath (const cmt_string& path, cmt_string& result);
42
43  static void dirname (const cmt_string& file_name, cmt_string& result);
44
45  static void name (const cmt_string& file, cmt_string& result);
46
47  static void get_suffix (const cmt_string& file, cmt_string& result);
48  static void get_dot_suffix (const cmt_string& file, cmt_string& result);
49  static bool has_prefix (const cmt_string& name);
50  static bool absolute_path (const cmt_string& name);
51  static bool has_device (const cmt_string& name);
52
53  static cmt_string current_branch ();
54
55    /**
56     * Implementation of the "test -d" equivalent
57     */
58  static bool test_directory (const cmt_string& name);
59    /**
60     * Implementation of the "test -f" equivalent
61     */               
62  static bool test_file (const cmt_string& name);
63    /**
64     * Implementation of the "touch" function equivalent
65     */               
66  static bool touch_file (const cmt_string& name);   
67    /**
68     * Check if the file "name1" is identical to "name2"
69     */
70  static bool compare_files (const cmt_string& name1,
71                             const cmt_string& name2);
72    /**
73     * Check if the file "name1" is identical to "name2"
74     * if they are identical, "name1" will be simply deleted
75     * otherwise "name1" will be copied to "name2" and deleted afterwards
76     */
77  static bool compare_and_update_files (const cmt_string& name1,
78                                        const cmt_string& name2);
79  static int file_size (const cmt_string& name);
80  static char file_separator ();
81  static void reduce_file_separators (cmt_string& text);
82  static char path_separator ();
83  static char command_separator ();
84  static const cmt_string& ev_open ();
85  static const cmt_string& ev_close ();
86  static bool create_symlink (const cmt_string& oldname,
87                              const cmt_string& newname);
88  static bool remove_file (const cmt_string& name);
89  static bool remove_directory (const cmt_string& name);
90  static bool mkdir (const cmt_string& name);
91  static void scan_dir (const cmt_string& dir_name,
92                        cmt_string_vector& list);
93  static void scan_dir (const cmt_string& dir_name,
94                        const cmt_regexp& expression,
95                        cmt_string_vector& list);
96  static cmt_string_vector& scan_dir (const cmt_string& dir_name);
97  static const cmt_string& get_cmt_root ();
98  static void get_cmt_version (cmt_string& version);
99  static cmt_string get_cmt_config ();
100  static cmt_string get_cmt_site ();
101  static void get_uname (cmt_string& uname);
102  static void get_hosttype (cmt_string& hosttype);
103  static cmt_string get_temporary_name ();
104 
105  static cmt_string get_home_package ();
106  static bool is_home_package (const cmt_string& name,
107                               const cmt_string& version);
108 
109  static cmt_string get_user_context_package ();
110  static bool is_user_context_package (const cmt_string& name,
111                                       const cmt_string& version);
112 
113  static cmt_string get_project_package ();
114  static bool is_project_package (const cmt_string& name,
115                                  const cmt_string& version);
116 
117  static bool testenv (const cmt_string& name);
118  static cmt_string getenv (const cmt_string& name);
119  static bool putenv (const cmt_string& name, const cmt_string& value);
120  static void get_cmt_paths (IProjectFactory& factory,
121                             const cmt_string& init_text,
122                             const cmt_string& cmt_user_context,
123                             const cmt_string& cmt_home);
124  static int execute (const cmt_string& command);
125  static int execute (const cmt_string& command, cmt_string& output);
126  static bool is_package_directory (const cmt_string& name);
127  static bool is_version_directory (const cmt_string& name);
128  static bool is_version_directory (const cmt_string& name, int& v, int& r, int& p);
129  static void split (const cmt_string& text,
130                     const cmt_string& separators,
131                     cmt_string_vector& strings);
132
133  static void compress_path (const cmt_string& dir, cmt_string& new_dir);
134  static void compress_path (cmt_string& dir);
135
136  static cmt_string now ();
137  static cmt_string user ();
138
139  static void get_cvsroot (cmt_string& cvsroot);
140
141  static bool get_home_directory (cmt_string& dir);
142
143  static cmt_string get_makefile_suffix ();
144
145};
146
147#endif
Note: See TracBrowser for help on using the repository browser.