add directory_options
This commit is contained in:
parent
c09e7b7ba6
commit
3f446e9a0c
@ -175,7 +175,13 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
||||||
};
|
};
|
||||||
//enum class copy_options;
|
//enum class copy_options;
|
||||||
//enum class directory_options;
|
|
||||||
|
enum class directory_options
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
follow_directory_symlink,
|
||||||
|
skip_permission_denied
|
||||||
|
};
|
||||||
|
|
||||||
struct space_info
|
struct space_info
|
||||||
{
|
{
|
||||||
@ -357,7 +363,8 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
directory_iterator() noexcept;
|
directory_iterator() noexcept;
|
||||||
explicit directory_iterator(const path& dir);
|
explicit directory_iterator(const path& p);
|
||||||
|
directory_iterator(const path& p, directory_options opt);
|
||||||
|
|
||||||
const value_type& operator*() const;
|
const value_type& operator*() const;
|
||||||
const value_type* operator->() const;
|
const value_type* operator->() const;
|
||||||
@ -381,6 +388,7 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
private:
|
private:
|
||||||
bool end_{false};
|
bool end_{false};
|
||||||
path::string_type path_;
|
path::string_type path_;
|
||||||
|
directory_options option_{ directory_options::opt };
|
||||||
|
|
||||||
std::shared_ptr<find_handle> find_ptr_;
|
std::shared_ptr<find_handle> find_ptr_;
|
||||||
find_handle handle_{nullptr};
|
find_handle handle_{nullptr};
|
||||||
|
@ -102,6 +102,22 @@ namespace nana
|
|||||||
|
|
||||||
std::string pretty_file_date(const fs::path& path) // todo: move to .cpp
|
std::string pretty_file_date(const fs::path& path) // todo: move to .cpp
|
||||||
{
|
{
|
||||||
|
struct tm t;
|
||||||
|
if (modified_file_time(path, t))
|
||||||
|
{
|
||||||
|
std::stringstream tm;
|
||||||
|
tm << std::put_time(&t, "%Y-%m-%d, %H:%M:%S");
|
||||||
|
return tm.str();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Deprecated
|
||||||
|
//Windows stores file times using the FILETIME structure, which is a 64 bit value of 100ns intervals from January 1, 1601.
|
||||||
|
//What's worse is that this 1601 date is fairly common to see given that it's the all zeroes value, and it is far before the
|
||||||
|
//earliest date representable with time_t.std::filesystem can't change the reality of the underlying platform.
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if NANA_USING_BOOST_FILESYSTEM
|
#if NANA_USING_BOOST_FILESYSTEM
|
||||||
// The return type of boost::filesystem::last_write_time isn't
|
// The return type of boost::filesystem::last_write_time isn't
|
||||||
@ -117,7 +133,9 @@ namespace nana
|
|||||||
|
|
||||||
if (ftime == ((fs::file_time_type::min)())) return{};
|
if (ftime == ((fs::file_time_type::min)())) return{};
|
||||||
|
|
||||||
auto cftime = static_cast<std::time_t>(ftime.time_since_epoch().count());
|
//A workaround for VC2013
|
||||||
|
using time_point = decltype(ftime);
|
||||||
|
auto cftime = time_point::clock::to_time_t(ftime);
|
||||||
|
|
||||||
std::stringstream tm;
|
std::stringstream tm;
|
||||||
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||||
@ -126,6 +144,8 @@ namespace nana
|
|||||||
catch (...) {
|
catch (...) {
|
||||||
return{};
|
return{};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool modified_file_time(const fs::path& p, struct tm& t)
|
bool modified_file_time(const fs::path& p, struct tm& t)
|
||||||
@ -442,6 +462,8 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
{
|
{
|
||||||
#ifdef NANA_WINDOWS
|
#ifdef NANA_WINDOWS
|
||||||
std::replace(pathstr_.begin(), pathstr_.end(), L'/', L'\\');
|
std::replace(pathstr_.begin(), pathstr_.end(), L'/', L'\\');
|
||||||
|
#else
|
||||||
|
std::replace(pathstr_.begin(), pathstr_.end(), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -652,6 +674,12 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
_m_prepare(file_path);
|
_m_prepare(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directory_iterator::directory_iterator(const path& p, directory_options opt):
|
||||||
|
option_(opt)
|
||||||
|
{
|
||||||
|
_m_prepare(p);
|
||||||
|
}
|
||||||
|
|
||||||
const directory_iterator::value_type& directory_iterator::operator*() const { return value_; }
|
const directory_iterator::value_type& directory_iterator::operator*() const { return value_; }
|
||||||
|
|
||||||
const directory_iterator::value_type*
|
const directory_iterator::value_type*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user