C++ main module for emicrom 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 
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();
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
71  static tBoolean exists(const tString& filename);
72 
76  static tBoolean isPath(const tString& path);
77 
81  static tBoolean isFile(const tString& file);
82 
86  static tBoolean removeFile(const tString& filename);
91  static inline tBoolean removePath(const tString& path) {
92  return removeDirectory(path,true);
93  };
98  static inline tBoolean removeDirectory(const tString& path) {
99  return removeDirectory(path,true);
100  };
101 
107  static inline tBoolean removePath(const tString& path,const tBoolean& removeOnlyEmptyDir) {
108  return removeDirectory(path,removeOnlyEmptyDir);
109  };
115  static tBoolean removeDirectory(const tString& path,const tBoolean& removeOnlyEmptyDir);
116 
121  static inline tBoolean createPath(const tString& path) {
122  return createDirectory(path);
123  };
128  static tBoolean createDirectory(const tString& path);
129 
130 
136  static void getPathAndFileName(const tString& file,
137  tString& path,
138  tString& fileName);
139 
140 
146  static tString getExtension(const tString& file);
147 
148 
153  static tString getPrefix(const tString& file);
154 
159  static tString getBasename(const tString& file);
160 
165  static void setExtension(tString& file,const tString& ext);
166 
167  // GET
168 
175  static tBoolean getFiles(const tString& path,
176  const tString& filter,
177  CORE_StringVector& files);
184  static tBoolean getFiles(const tString& path,
185  const tString& filter,
186  vector<tString>& files);
187 
188 
193  static tBoolean cp(const tString& src,const tString& dest);
198  static tBoolean mv(const tString& src,const tString& dest);
199 
205  static tBoolean getContents(const tString& path,
206  CORE_StringVector& files);
207 
208 
212  static tString getCurrentPath();
213 
218  static void getPaths(const tString& rootPath,CORE_StringVector& paths);
219 
220 
221 
222 
226  static void beginRedirectOutputToFile(const tString& fn);
229  static void beginRedirectOutputToString();
233  static void endRedirectOutput(tString& message);
234 
235  };
236 
237 #endif
static tString getBasename(const tString &file)
get the base nname of the file
Definition: CORE_IO.cpp:321
static void beginRedirectOutputToString()
redirection of the output to string
Definition: CORE_IO.cpp:278
static streambuf * COUT_BUFFER
Definition: CORE_IO.h:33
static tBoolean mv(const tString &src, const tString &dest)
move file
Definition: CORE_IO.cpp:430
this class describes an array
Definition: CORE_Vector.h:19
static void endRedirectOutput(tString &message)
end of redirection of the output to file
Definition: CORE_IO.cpp:293
DEFINE_SPTR(CORE_IO)
static tBoolean getFiles(const tString &path, const tString &filter, CORE_StringVector &files)
get all files in path with filter in files vector
Definition: CORE_IO.cpp:145
static tBoolean removeDirectory(const tString &path)
remove the path if and only if the path is empty
Definition: CORE_IO.h:98
this class describes the IO class
Definition: CORE_IO.h:18
static tString getExtension(const tString &file)
get the extension toto.html => html @ param file : name to find the extension
Definition: CORE_IO.cpp:41
static tString getPrefix(const tString &file)
get the prefix ie all the name before the last .
Definition: CORE_IO.cpp:68
static tBoolean cp(const tString &src, const tString &dest)
copy file
Definition: CORE_IO.cpp:417
static tBoolean exists(const tString &filename)
test if the file or path exists
Definition: CORE_IO.cpp:409
#define tBoolean
Definition: types.h:139
static tBoolean createDirectory(const tString &path)
create the path
Definition: CORE_IO.cpp:332
CORE_IO()
build a CORE_IO
Definition: CORE_IO.cpp:34
static void getPathAndFileName(const tString &file, tString &path, tString &fileName)
get the path and file name
Definition: CORE_IO.cpp:83
static tBoolean removeFile(const tString &filename)
remove the file
Definition: CORE_IO.cpp:339
static tBoolean createPath(const tString &path)
create the path
Definition: CORE_IO.h:121
static void beginRedirectOutputToFile(const tString &fn)
redirection of the output to file
Definition: CORE_IO.cpp:264
static void setExtension(tString &file, const tString &ext)
set the extension
Definition: CORE_IO.cpp:51
static void getPaths(const tString &rootPath, CORE_StringVector &paths)
get the all the paths of the root path
Definition: CORE_IO.cpp:131
static tBoolean removePath(const tString &path, const tBoolean &removeOnlyEmptyDir)
remove the path
Definition: CORE_IO.h:107
static tBoolean isPath(const tString &path)
test if the file is a path
Definition: CORE_IO.cpp:386
static tString getCurrentPath()
get the current path
Definition: CORE_IO.cpp:312
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:53
#define tString
Definition: types.h:135
static tBoolean getContents(const tString &path, CORE_StringVector &files)
get all contents of path
Definition: CORE_IO.cpp:110
SP_OBJECT(CORE_IO)
static ostringstream * COUT_STRING
Definition: CORE_IO.h:32
static tBoolean removePath(const tString &path)
remove the path if and only if the path is empty
Definition: CORE_IO.h:91
static tBoolean isFile(const tString &file)
test if the file is a regular file
Definition: CORE_IO.cpp:398
static ofstream * COUT_FILE
Definition: CORE_IO.h:31
virtual ~CORE_IO()
destroy a CORE_IO
Definition: CORE_IO.cpp:38
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141