diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp index c44345c6..1bbe3aa9 100644 --- a/include/nana/filesystem/filesystem.hpp +++ b/include/nana/filesystem/filesystem.hpp @@ -127,23 +127,41 @@ namespace nana { namespace experimental { namespace filesystem _m_assign(source); } + // modifiers + //void clear() noexcept; + path& make_preferred(); + path& remove_filename(); + //path& replace_filename(const path& replacement); + //path& replace_extension(const path& replacement = path()); + //void swap(path& rhs) noexcept; + + // decomposition + //path root_name() const; + //path root_directory() const; + //path root_path() const; + //path relative_path() const; + path parent_path() const; + path filename() const; + //path stem() const; + path extension() const; + + // query + bool empty() const noexcept; + //bool has_root_name() const; + //bool has_root_directory() const; + //bool has_root_path() const; + //bool has_relative_path() const; + bool has_parent_path() const { return !parent_path().empty(); }; // temp;; + bool has_filename() const { return !filename().empty(); }; // temp; + //bool has_stem() const; + bool has_extension() const { return !extension().empty(); }; // temp + //bool is_absolute() const; + //bool is_relative() const; int compare(const path& other) const; - bool empty() const; - path extension() const; - - path parent_path() const; file_type what() const; - //decomposition - path filename() const; - - //modifiers - path& remove_filename(); - - - const value_type*c_str() const; const string_type& native() const; operator string_type() const; @@ -335,16 +353,21 @@ namespace nana { namespace experimental { namespace filesystem bool create_directory(const path& p, const path& attributes); //bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept; - bool modified_file_time(const path& p, struct tm&); + bool modified_file_time(const path& p, struct tm&); ///< extention ? + + /// The time of last data modification of p, determined as if by the value of the POSIX + /// stat structure member st_mtime obtained as if by POSIX stat(). + file_time_type last_write_time(const path& p); + /// returns file_time_type::min() if an error occurs + //file_time_type last_write_time(const path& p, error_code& ec) noexcept; path path_user(); ///< extention ? - + path current_path(); //path current_path(error_code& ec); void current_path(const path& p); ///< chdir //void current_path(const path& p, error_code& ec) noexcept; - bool remove(const path& p); bool remove(const path& p, std::error_code& ec); // noexcept; diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 63795147..1f523f3a 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -110,7 +110,7 @@ namespace nana { namespace experimental { namespace filesystem return pathstr_.compare(p.pathstr_); } - bool path::empty() const + bool path::empty() const noexcept { #if defined(NANA_WINDOWS) return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES); @@ -781,6 +781,13 @@ namespace nana { namespace experimental { namespace filesystem return false; } + file_time_type last_write_time(const path& p) + { + struct tm t; + modified_file_time(p, t); + std::chrono::system_clock::time_point dateTime =std::chrono::system_clock::from_time_t( mktime(&t) ); + return dateTime; + } bool create_directory(const path& p) {