source: CMT/v1r18p20060505/source/cmt_system.h

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

add get_make_suffix function

  • Property svn:eol-style set to native
File size: 5.0 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  static void dirname (const cmt_string& file_name, cmt_string& result);
41
42  static void name (const cmt_string& file, cmt_string& result);
43
44  static void get_suffix (const cmt_string& file, cmt_string& result);
45  static void get_dot_suffix (const cmt_string& file, cmt_string& result);
46  static bool has_prefix (const cmt_string& name);
47  static bool absolute_path (const cmt_string& name);
48  static bool has_device (const cmt_string& name);
49
50  static cmt_string current_branch ();
51
52    /**
53     * Implementation of the "test -d" equivalent
54     */
55  static bool test_directory (const cmt_string& name);
56    /**
57     * Implementation of the "test -f" equivalent
58     */
59  static bool test_file (const cmt_string& name);
60    /**
61     * Check if the file "name1" is identical to "name2"
62     */
63  static bool compare_files (const cmt_string& name1,
64                             const cmt_string& name2);
65    /**
66     * Check if the file "name1" is identical to "name2"
67     * if they are identical, "name1" will be simply deleted
68     * otherwise "name1" will be copied to "name2" and deleted afterwards
69     */
70  static bool compare_and_update_files (const cmt_string& name1,
71                                        const cmt_string& name2);
72  static int file_size (const cmt_string& name);
73  static char file_separator ();
74  static void reduce_file_separators (cmt_string& text);
75  static char path_separator ();
76  static char command_separator ();
77  static const cmt_string& ev_open ();
78  static const cmt_string& ev_close ();
79  static bool create_symlink (const cmt_string& oldname,
80                              const cmt_string& newname);
81  static bool remove_file (const cmt_string& name);
82  static bool remove_directory (const cmt_string& name);
83  static bool mkdir (const cmt_string& name);
84  static void scan_dir (const cmt_string& dir_name,
85                        cmt_string_vector& list);
86  static void scan_dir (const cmt_string& dir_name,
87                        const cmt_regexp& expression,
88                        cmt_string_vector& list);
89  static cmt_string_vector& scan_dir (const cmt_string& dir_name);
90  static const cmt_string& get_cmt_root ();
91  static void get_cmt_version (cmt_string& version);
92  static cmt_string get_cmt_config ();
93  static cmt_string get_cmt_site ();
94  static void get_uname (cmt_string& uname);
95  static void get_hosttype (cmt_string& hosttype);
96  static cmt_string get_temporary_name ();
97 
98  static cmt_string get_home_package ();
99  static bool is_home_package (const cmt_string& name,
100                               const cmt_string& version);
101 
102  static cmt_string get_user_context_package ();
103  static bool is_user_context_package (const cmt_string& name,
104                                       const cmt_string& version);
105 
106  static cmt_string get_project_package ();
107  static bool is_project_package (const cmt_string& name,
108                                  const cmt_string& version);
109 
110  static bool testenv (const cmt_string& name);
111  static cmt_string getenv (const cmt_string& name);
112  static bool putenv (const cmt_string& name, const cmt_string& value);
113  static void get_cmt_paths (IProjectFactory& factory,
114                             const cmt_string& init_text,
115                             const cmt_string& cmt_user_context,
116                             const cmt_string& cmt_home);
117  static int execute (const cmt_string& command);
118  static int execute (const cmt_string& command, cmt_string& output);
119  static bool is_package_directory (const cmt_string& name);
120  static bool is_version_directory (const cmt_string& name);
121  static bool is_version_directory (const cmt_string& name, int& v, int& r, int& p);
122  static void split (const cmt_string& text,
123                     const cmt_string& separators,
124                     cmt_string_vector& strings);
125
126  static void compress_path (const cmt_string& dir, cmt_string& new_dir);
127  static void compress_path (cmt_string& dir);
128
129  static cmt_string now ();
130  static cmt_string user ();
131
132  static void get_cvsroot (cmt_string& cvsroot);
133
134  static bool get_home_directory (cmt_string& dir);
135
136  static cmt_string get_makefile_suffix ();
137
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.