/* */ #ifndef D_FILE_H #define D_FILE_H #include "common.h" #include #include "a2io.h" #include "TimeA2.h" namespace aria2 { /** * Represents file and directory */ class File { private: std::string name_; /** * Returns the return value of stat(...) */ int fillStat(a2_struct_stat& fstat); public: File(const std::string& name); File(const File& c); ~File(); File& operator=(const File& c); /** * 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(); off_t size(); mode_t mode(); std::string getBasename() const; std::string getDirname() const; const std::string& getPath() const { return name_; } static bool isDir(const std::string& filename); bool renameTo(const std::string& dest); bool utime(const Time& actime, const Time& modtime) const; Time getModifiedTime(); // Returns the current working directory. If the current working // directory cannot be retrieved or its length is larger than 2048, // returns ".". static std::string getCurrentDir(); // Returns possible path separators for the underlining platform. static const std::string& getPathSeparators(); }; } // namespace aria2 #endif // D_FILE_H