C++ main module for gpm Package  1.0
CORE_IO.h
Go to the documentation of this file.
1 #ifndef CORE_IO_H
2 #define CORE_IO_H
3 
4 
5 #include "CORE_Object.h"
6 #include "CORE_Integer.h"
7 #include "CORE_Real.h"
8 #include "CORE_String.h"
9 #include "CORE_Array.h"
10 
18 class CORE_IO : public CORE_Object { // class
19 
20  SP_OBJECT(CORE_IO);
21 
22  // ATTRIBUTES
23 
24  public:
25 
26 
27 
28 
29  private:
30 
31  static ofstream *COUT_FILE;
32  static ostringstream *COUT_STRING;
33  static streambuf *COUT_BUFFER;
34 
35  // ASSOCIATIONS
36 
37 
38  // METHODS
39 
40 
41  protected:
42  // CONSTRUCTORS
45  CORE_IO();
46 
47 
48 
49 
50  // DESTRUCTORS
54  virtual ~CORE_IO(void);
55 
56 
57  public:
58  // NEW
61  inline static SP::CORE_IO New(){
62  SP::CORE_IO p(new CORE_IO(),CORE_IO::Delete());
63  return p;
64  };
65 
66 
67  // SET
70  static tBoolean exists(const tString& filename);
73  static tBoolean isPath(const tString& file);
76  static tBoolean isFile(const tString& file);
77 
80  static tBoolean removeFile(const tString& filename);
84  static inline tBoolean removePath(const tString& path) {
85  return removeDirectory(path,true);
86  };
90  static inline tBoolean removeDirectory(const tString& path) {
91  return removeDirectory(path,true);
92  };
93 
97  static inline tBoolean removePath(const tString& path,const tBoolean& removeOnlyEmptyDir) {
98  return removeDirectory(path,removeOnlyEmptyDir);
99  };
103  static tBoolean removeDirectory(const tString& path,const tBoolean& removeOnlyEmptyDir);
104 
108  static inline tBoolean createPath(const tString& path) {
109  return createDirectory(path);
110  };
114  static tBoolean createDirectory(const tString& path);
115 
116 
119  static void getPathAndFileName(const tString& file,
120  tString& path,
121  tString& fileName);
122 
123 
127  static tString getExtension(const tString& file);
128 
129 
132  static tString getPrefix(const tString& file);
133 
136  static tString getBasename(const tString& file);
137 
140  static void setExtension(tString& file,const tString& ext);
141 
142  // GET
143 
150  static tBoolean getFiles(const tString& path,
151  const tString& filter,
152  CORE_StringArray& files);
159  static tBoolean getFiles(const tString& path,
160  const tString& filter,
161  vector<tString>& files);
162 
163 
166  static tBoolean cp(const tString& src,const tString& dest);
169  static tBoolean mv(const tString& src,const tString& dest);
170 
176  static tBoolean getContents(const tString& path,
177  CORE_StringArray& files);
178 
179 
182  static tString getCurrentPath();
183 
186  static void getPaths(const tString& rootPath,CORE_StringArray& paths);
187 
188 
189 
190 
193  static void beginRedirectOutputToFile(const tString& fn);
196  static void beginRedirectOutputToString();
199  static void endRedirectOutput(tString& message);
200 
201  };
202 
203 #endif
static tString getBasename(const tString &file)
get the base nname of the file
Definition: CORE_IO.cpp:269
static void beginRedirectOutputToString()
redirection of the output to string
Definition: CORE_IO.cpp:230
static tBoolean mv(const tString &src, const tString &dest)
move file
Definition: CORE_IO.cpp:340
static void endRedirectOutput(tString &message)
end of redirection of the output to file
Definition: CORE_IO.cpp:245
DEFINE_SPTR(CORE_IO)
static tBoolean isPath(const tString &file)
test if the file is a path
Definition: CORE_IO.cpp:298
static tBoolean removeDirectory(const tString &path)
remove the path if and only if the path is empty
Definition: CORE_IO.h:90
this class describes the IO class
Definition: CORE_IO.h:18
static tString getExtension(const tString &file)
get the extension toto.html => html
Definition: CORE_IO.cpp:24
static tString getPrefix(const tString &file)
get the prefix ie all the name before the last .
Definition: CORE_IO.cpp:51
static tBoolean cp(const tString &src, const tString &dest)
copy file
Definition: CORE_IO.cpp:327
static tBoolean exists(const tString &filename)
test if the file or path exists
Definition: CORE_IO.cpp:319
#define tBoolean
Definition: types.h:35
static tBoolean createDirectory(const tString &path)
create the path return false if the path does not exists
Definition: CORE_IO.cpp:274
CORE_IO()
build a CORE_IO
Definition: CORE_IO.cpp:16
static void getPathAndFileName(const tString &file, tString &path, tString &fileName)
get the path and file name
Definition: CORE_IO.cpp:66
static tBoolean removeFile(const tString &filename)
remove the file
Definition: CORE_IO.cpp:290
static tBoolean createPath(const tString &path)
create the path return false if the path does not exists
Definition: CORE_IO.h:108
static void beginRedirectOutputToFile(const tString &fn)
redirection of the output to file
Definition: CORE_IO.cpp:216
static void setExtension(tString &file, const tString &ext)
set the extension
Definition: CORE_IO.cpp:34
this class describes an array
Definition: CORE_Array.h:18
static tBoolean removePath(const tString &path, const tBoolean &removeOnlyEmptyDir)
remove the path
Definition: CORE_IO.h:97
static tString getCurrentPath()
get the current path
Definition: CORE_IO.cpp:264
static SP::CORE_IO New()
create a new CORE_Io class
Definition: CORE_IO.h:61
abstract base class for most classes.
Definition: CORE_Object.h:30
static tBoolean getFiles(const tString &path, const tString &filter, CORE_StringArray &files)
get all files in path with filter in files vector
Definition: CORE_IO.cpp:127
#define tString
Definition: types.h:36
static void getPaths(const tString &rootPath, CORE_StringArray &paths)
get the all the paths of the root path
Definition: CORE_IO.cpp:113
static tBoolean getContents(const tString &path, CORE_StringArray &files)
get all contents of path
Definition: CORE_IO.cpp:93
static tBoolean removePath(const tString &path)
remove the path if and only if the path is empty
Definition: CORE_IO.h:84
static tBoolean isFile(const tString &file)
test if the file is a regular file
Definition: CORE_IO.cpp:308
virtual ~CORE_IO(void)
destroy a CORE_IO
Definition: CORE_IO.cpp:21
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106