| 1 |
// Class Path : methods on strings which represents the path of file or directory |
| 2 |
// |
| 3 |
// For all support, instructions and copyright go to: |
| 4 |
// http://e2guardian.org/ |
| 5 |
// Released under the GPL v2, with the OpenSSL exception described in the README file. |
| 6 |
|
| 7 |
#ifndef __HPP_PATH |
| 8 |
#define __HPP_PATH |
| 9 |
|
| 10 |
// INCLUDES |
| 11 |
|
| 12 |
#include <iostream> |
| 13 |
#include <string> |
| 14 |
#include <sys/types.h> |
| 15 |
|
| 16 |
// DECLARATIONS |
| 17 |
|
| 18 |
class Path |
| 19 |
{ |
| 20 |
private: |
| 21 |
std::string _path; |
| 22 |
|
| 23 |
public: |
| 24 |
Path() { _path = ""; }; |
| 25 |
~Path(); |
| 26 |
|
| 27 |
// properties |
| 28 |
std::string fullPath() const { return _path; } |
| 29 |
|
| 30 |
// constructor from c-string |
| 31 |
Path(const char *bs) { _path = bs; }; |
| 32 |
// constructor from std-string |
| 33 |
Path(std::string ss) { _path = ss; }; |
| 34 |
// copy constructor |
| 35 |
Path(const Path &p) { _path = p._path; }; |
| 36 |
|
| 37 |
// return to base dir (for file paths) |
| 38 |
Path baseDir() const; |
| 39 |
|
| 40 |
// appends to this base dir a relative_path |
| 41 |
void append(const Path &relative_path); |
| 42 |
|
| 43 |
// combines this base dir and a relative_path |
| 44 |
Path combine(const Path &relative_path); |
| 45 |
|
| 46 |
}; |
| 47 |
#endif |