Rev | Line | |
---|
[7609] | 1 | /*! |
---|
| 2 | * @file file.h |
---|
| 3 | * @brief Definition of File Handler class |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef __FILE_H_ |
---|
| 7 | #define __FILE_H_ |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | #include <string> |
---|
[7616] | 11 | typedef struct stat; |
---|
[7609] | 12 | |
---|
| 13 | class File |
---|
| 14 | { |
---|
| 15 | public: |
---|
| 16 | typedef enum |
---|
| 17 | { |
---|
| 18 | ReadOnly, |
---|
| 19 | WriteOnly, |
---|
| 20 | ReadWrite, |
---|
| 21 | Append, |
---|
| 22 | } OpenMode; |
---|
| 23 | |
---|
| 24 | public: |
---|
| 25 | File(const std::string& fileName); |
---|
| 26 | File(const File& file); |
---|
| 27 | ~File(); |
---|
| 28 | |
---|
| 29 | virtual bool open(OpenMode mode); |
---|
| 30 | virtual bool close(); |
---|
| 31 | int handle(); |
---|
| 32 | |
---|
[7616] | 33 | /** @returns the FileName of this File */ |
---|
| 34 | const std::string& name() const { return this->_name; }; |
---|
| 35 | |
---|
[7609] | 36 | bool exists(); |
---|
[7611] | 37 | bool isLink(); // only on UNIX |
---|
[7609] | 38 | bool isFile(); |
---|
[7611] | 39 | bool isDirectory(); |
---|
[7609] | 40 | bool isReadeable(); |
---|
| 41 | bool isWriteable(); |
---|
| 42 | bool isExecutable(); |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | bool copy(const File& destination); |
---|
| 46 | bool rename(const File& destination); |
---|
| 47 | bool touch(); |
---|
| 48 | bool remove(); |
---|
| 49 | |
---|
| 50 | static void relToAbs(std::string& fileName); |
---|
[7611] | 51 | static void absToRel(std::string& fileName); |
---|
| 52 | static const std::string& cwd(); |
---|
[7609] | 53 | |
---|
| 54 | private: |
---|
[7616] | 55 | void init(); |
---|
[7618] | 56 | bool statFile(); |
---|
[7609] | 57 | void homeDirCheck(std::string& fileName); |
---|
| 58 | |
---|
| 59 | private: |
---|
[7611] | 60 | int _handle; //!< The FileHandle (if set). |
---|
[7616] | 61 | std::string _name; //!< The Name of the File. |
---|
| 62 | stat* _status; //!< The Stat of the File. |
---|
[7611] | 63 | |
---|
| 64 | static std::string _cwd; //!< The currend Working directory. |
---|
[7616] | 65 | |
---|
[7609] | 66 | }; |
---|
| 67 | |
---|
[7611] | 68 | #endif /* __FILE_H_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.