/* */ #ifndef _D_FILE_H_ #define _D_FILE_H_ #include "common.h" #include #include #include using namespace std; /** * Represents file and directory */ class File { private: string name; /** * Returns the return value of stat(...) */ int32_t fillStat(struct stat& fstat); public: File(const string& name); ~File(); /** * Tests whether the file or directory denoted by name exists. */ bool exists(); /** * Tests whether the file denoted by name is a regular file. */ bool isFile(); /** * Tests whether the file denoted by name is a directory. */ bool isDir(); /** * Deletes the file or directory denoted by name. * If name denotes a directory, it must be empty in order to delete. */ bool remove(); /** * Creates the directory denoted by name. * This method creates complete directory structure. * Returns true if the directory is created successfully, otherwise returns * false. * If the directory already exists, then returns false. */ bool mkdirs(); int64_t size(); mode_t mode(); string getBasename() const; string getDirname() const; }; #endif // _D_FILE_H_