Line | |
---|
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> |
---|
11 | typedef struct stat; |
---|
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 | |
---|
33 | /** @returns the FileName of this File */ |
---|
34 | const std::string& name() const { return this->_name; }; |
---|
35 | |
---|
36 | bool exists(); |
---|
37 | bool isLink(); // only on UNIX |
---|
38 | bool isFile(); |
---|
39 | bool isDirectory(); |
---|
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); |
---|
51 | static void absToRel(std::string& fileName); |
---|
52 | static const std::string& cwd(); |
---|
53 | |
---|
54 | private: |
---|
55 | void init(); |
---|
56 | bool statFile(); |
---|
57 | void homeDirCheck(std::string& fileName); |
---|
58 | |
---|
59 | private: |
---|
60 | int _handle; //!< The FileHandle (if set). |
---|
61 | std::string _name; //!< The Name of the File. |
---|
62 | stat* _status; //!< The Stat of the File. |
---|
63 | |
---|
64 | static std::string _cwd; //!< The currend Working directory. |
---|
65 | |
---|
66 | }; |
---|
67 | |
---|
68 | #endif /* __FILE_H_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.