FIX filebox in linux with fs_ext
This commit is contained in:
@@ -359,7 +359,6 @@ 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&); ///< 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().
|
||||
@@ -367,7 +366,6 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
/// 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);
|
||||
|
||||
@@ -34,15 +34,14 @@ namespace filesystem_ext
|
||||
constexpr auto def_rootstr = "/";
|
||||
constexpr auto def_rootname = "Root/";
|
||||
#endif
|
||||
|
||||
// nana::experimental::filesystem::path_user());
|
||||
|
||||
std::experimental::filesystem::path path_user(); ///< extention ?
|
||||
|
||||
inline bool is_directory(const std::experimental::filesystem::directory_entry& dir) noexcept
|
||||
{
|
||||
return is_directory(dir.status());
|
||||
}
|
||||
|
||||
|
||||
//template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
|
||||
class directory_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||
{
|
||||
@@ -84,7 +83,6 @@ inline directory_only_iterator end(const directory_only_iterator&) noexcept
|
||||
return{};
|
||||
}
|
||||
|
||||
|
||||
//template<class DI> // DI = directory_iterator from std, boost, or nana : value_type directory_entry
|
||||
class regular_file_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||
{
|
||||
@@ -121,60 +119,11 @@ inline regular_file_only_iterator end(const regular_file_only_iterator&) noexcep
|
||||
return{};
|
||||
}
|
||||
|
||||
inline std::string pretty_file_size(const std::experimental::filesystem::path& path) // todo: move to .cpp
|
||||
{
|
||||
try {
|
||||
auto bytes = std::experimental::filesystem::file_size ( path );
|
||||
const char * ustr[] = { " KB", " MB", " GB", " TB" };
|
||||
std::stringstream ss;
|
||||
if (bytes < 1024)
|
||||
ss << bytes << " Bytes";
|
||||
else
|
||||
{
|
||||
double cap = bytes / 1024.0;
|
||||
std::size_t uid = 0;
|
||||
while ((cap >= 1024.0) && (uid < sizeof(ustr) / sizeof(char *)))
|
||||
{
|
||||
cap /= 1024.0;
|
||||
++uid;
|
||||
}
|
||||
ss << cap;
|
||||
auto s = ss.str();
|
||||
auto pos = s.find('.');
|
||||
if (pos != s.npos)
|
||||
{
|
||||
if (pos + 2 < s.size())
|
||||
s.erase(pos + 2);
|
||||
}
|
||||
return s + ustr[uid];
|
||||
}
|
||||
std::string pretty_file_size(const std::experimental::filesystem::path& path);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
catch (...) {}
|
||||
return {};
|
||||
}
|
||||
std::string pretty_file_date(const std::experimental::filesystem::path& path);
|
||||
|
||||
inline std::string pretty_file_date(const std::experimental::filesystem::path& path) // todo: move to .cpp
|
||||
{
|
||||
try {
|
||||
auto ftime = std::experimental::filesystem::last_write_time(path);
|
||||
|
||||
// crash: VS2015 will not read the time for some files (for example: C:/hiberfil.sys)
|
||||
// and will return file_time_type(-1) without throwing
|
||||
// https://msdn.microsoft.com/en-us/library/dn823784.aspx
|
||||
|
||||
if (ftime == ((std::experimental::filesystem::file_time_type::min)())) return {};
|
||||
|
||||
std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||
std::stringstream tm;
|
||||
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||
return tm.str();
|
||||
}
|
||||
catch (...) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
bool modified_file_time(const std::experimental::filesystem::path& p, struct tm&); ///< extention ?
|
||||
|
||||
} // filesystem_ext
|
||||
} // nana
|
||||
|
||||
Reference in New Issue
Block a user