a few more std features in filesystem

This commit is contained in:
qPCR4vir 2016-02-25 19:18:40 +01:00
parent 1dd42c8841
commit aad9e77804
2 changed files with 46 additions and 16 deletions

View File

@ -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,7 +353,13 @@ 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 ?
@ -344,7 +368,6 @@ namespace nana { namespace experimental { namespace filesystem
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;

View File

@ -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)
{