commore  1.0.6-SNAPSHOT
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Path.h
1 //
2 // Copyright (c) 2006-2014 Raphael David / CANTOR
3 //
4 
5 #ifndef CMR_PATH_INCLUDED
6 #define CMR_PATH_INCLUDED
7 
8 #include "Commore.h"
9 #include "AString.h"
10 #include "Directory.h"
11 #include "Time.h"
12 
13 
14 namespace commore
15 {
19  class CMREXD Path : public commore::AString
20  {
21  public:
22  Path() {}
26  Path(const AChar* path) : AString(path) {}
30  Path(const AChar* p0, const AChar* p1,
31  const AChar* p2 = "", const AChar* p3 = "",
32  const AChar* p4 = "", const AChar* p5 = "",
33  const AChar* p6 = "", const AChar* p7 = "");
37  operator const AChar* () const
38  {
39  return (const char*)(const AString&) * this;
40  }
41 
42  public:
51  void set(
52  const AChar* unc_host_name,
53  const AChar* drive_name,
54  const AChar* dir,
55  const AChar* base,
56  const AChar* ext);
65  void get(
66  AString& unc_host_name,
67  AString& drive_name,
68  AString& dir,
69  AString& base,
70  AString& ext);
74  AString get_extension() const;
78  AString get_base() const;
82  AString get_file_name() const;
86  AString get_directory() const;
90  AString get_path() const;
94  AString get_unc_host() const;
98  AString get_drive() const;
104  AString up() ;
108  AString top() const;
112  AString get_relative_path(const AString& path) const;
118  bool down(const AString& name);
129  void set_full_path();
130 
135  bool is_valid() const;
139  bool is_unc() const;
143  bool has_drive() const;
147  bool has_extension(const AString& ext) const;
151  bool check_extension(const AChar* ext) const;
155  bool check_base(const AChar* ext) const;
159  bool check_file_name(const AChar* ext) const;
163  bool check_directory(const AChar* ext) const;
167  bool check_path(const AChar* ext) const;
171  bool check_unc(const AChar* ext) const;
175  bool check_drive(const AChar* ext) const;
179  void set_extension(const AString& extension);
183  void set_base(const AString& base);
187  void set_file_name(const AString& fileName);
191  void set_directory(const AString& directory);
195  void set_path(const AString& path);
199  void set_unc_host(const AString& hostName);
203  void set_drive(const AString& drive);
209  void set_temp_path(const AChar* extension = "tmp");
214  bool exists() const;
220  bool delete_file(bool force = true) const;
226  bool move_file(const Path& new_path) const;
233  bool move_file(const Path& new_path, bool silent) const;
238  bool copy_to_file(const Path& dest_path) const;
242  bool set_read_only(bool read_only) const;
246  bool is_read_only() const;
250  bool is_directory() const;
256  bool lock_file(bool lock = true) const;
261  size_t get_size() const;
266  TimeDate get_last_modif_time() const;
267  };
268 
272  class CMREXD FileLock : public Path
273  {
274  public:
275  FileLock();
279  FileLock(const AChar* file_path);
280  FileLock& operator = (const AChar* file_path);
284  ~FileLock();
285 
286  public:
292  bool lock();
297  bool wait_lock();
301  void unlock();
302 
303  private:
304  FileLock(const FileLock&);
305  FileLock& operator = (const FileLock&);
306 
307  private:
308  void* h_;
309  };
310 };
311 
312 #endif
Definition: Path.h:272
Definition: AString.h:39
Definition: Path.h:19
Path(const AChar *path)
Definition: Path.h:26
Definition: Time.h:261