/*! * @file file.h * @brief Definition of File Handler class */ #ifndef __FILE_H_ #define __FILE_H_ #include typedef struct stat; class File { public: typedef enum { ReadOnly, WriteOnly, ReadWrite, Append, } OpenMode; public: File(const std::string& fileName); File(const File& file); ~File(); virtual bool open(OpenMode mode); virtual bool close(); int handle(); /** @returns the FileName of this File */ const std::string& name() const { return this->_name; }; bool exists(); bool isLink(); // only on UNIX bool isFile(); bool isDirectory(); bool isReadeable(); bool isWriteable(); bool isExecutable(); bool copy(const File& destination); bool rename(const File& destination); bool touch(); bool remove(); static void relToAbs(std::string& fileName); static void absToRel(std::string& fileName); static const std::string& cwd(); private: void init(); bool statFile(); void homeDirCheck(std::string& fileName); private: int _handle; //!< The FileHandle (if set). std::string _name; //!< The Name of the File. stat* _status; //!< The Stat of the File. static std::string _cwd; //!< The currend Working directory. }; #endif /* __FILE_H_ */