improve nana.filesystem
This commit is contained in:
@@ -234,7 +234,7 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
}
|
||||
|
||||
// modifiers
|
||||
//void clear() noexcept;
|
||||
void clear() noexcept;
|
||||
path& make_preferred();
|
||||
path& remove_filename();
|
||||
//path& replace_filename(const path& replacement);
|
||||
@@ -242,10 +242,10 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
//void swap(path& rhs) noexcept;
|
||||
|
||||
// decomposition
|
||||
//path root_name() const;
|
||||
//path root_directory() const;
|
||||
//path root_path() const;
|
||||
//path relative_path() const;
|
||||
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;
|
||||
@@ -253,16 +253,16 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
|
||||
// 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().string().empty(); }; // temp;;
|
||||
bool has_filename() const { return !filename().string().empty(); }; // temp;
|
||||
bool has_root_name() const { return !root_name().empty(); }
|
||||
bool has_root_directory() const { return !root_directory().empty(); }
|
||||
bool has_root_path() const { return !root_path().empty(); }
|
||||
bool has_relative_path() const { return !relative_path().empty(); }
|
||||
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().string().empty(); }; // temp
|
||||
//bool is_absolute() const;
|
||||
//bool is_relative() const;
|
||||
bool has_extension() const { return !extension().empty(); }; // temp
|
||||
bool is_absolute() const;
|
||||
bool is_relative() const;
|
||||
|
||||
int compare(const path& other) const;
|
||||
|
||||
@@ -523,11 +523,20 @@ namespace std {
|
||||
# else
|
||||
using namespace nana::experimental::filesystem::v1;
|
||||
# endif
|
||||
|
||||
} // filesystem
|
||||
} // experimental
|
||||
|
||||
namespace filesystem {
|
||||
using namespace std::experimental::filesystem;
|
||||
|
||||
#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
|
||||
path absolute(const path& p);
|
||||
path absolute(const path& p, std::error_code& err);
|
||||
|
||||
path canonical(const path& p);
|
||||
path canonical(const path& p, std::error_code& err);
|
||||
#endif
|
||||
}
|
||||
} // std
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace filesystem_ext
|
||||
constexpr auto const def_rootname = "Root/";
|
||||
#endif
|
||||
|
||||
std::experimental::filesystem::path path_user(); ///< extention ?
|
||||
std::filesystem::path path_user(); ///< extention ?
|
||||
|
||||
/// workaround Boost not having path.generic_u8string() - a good point for http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0251r0.pdf
|
||||
inline std::string generic_u8string(const std::experimental::filesystem::path& p)
|
||||
inline std::string generic_u8string(const std::filesystem::path& p)
|
||||
{
|
||||
#if NANA_USING_BOOST_FILESYSTEM
|
||||
return nana::to_utf8(p.generic_wstring());
|
||||
@@ -45,15 +45,15 @@ inline std::string generic_u8string(const std::experimental::filesystem::path& p
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool is_directory(const std::experimental::filesystem::directory_entry& dir) noexcept
|
||||
inline bool is_directory(const std::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
|
||||
class directory_only_iterator : public std::filesystem::directory_iterator
|
||||
{
|
||||
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||
using directory_iterator = std::filesystem::directory_iterator;
|
||||
|
||||
directory_only_iterator& find_first()
|
||||
{
|
||||
@@ -93,9 +93,9 @@ inline directory_only_iterator end(const directory_only_iterator&) noexcept
|
||||
}
|
||||
|
||||
//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
|
||||
class regular_file_only_iterator : public std::filesystem::directory_iterator
|
||||
{
|
||||
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||
using directory_iterator = std::filesystem::directory_iterator;
|
||||
regular_file_only_iterator& find_first()
|
||||
{
|
||||
while (((*this) != directory_iterator{}) && !is_regular_file((**this).status()))
|
||||
@@ -128,11 +128,11 @@ inline regular_file_only_iterator end(const regular_file_only_iterator&) noexcep
|
||||
return{};
|
||||
}
|
||||
|
||||
std::string pretty_file_size(const std::experimental::filesystem::path& path);
|
||||
std::string pretty_file_size(const std::filesystem::path& path);
|
||||
|
||||
std::string pretty_file_date(const std::experimental::filesystem::path& path);
|
||||
std::string pretty_file_date(const std::filesystem::path& path);
|
||||
|
||||
bool modified_file_time(const std::experimental::filesystem::path& p, struct tm&); ///< extention ?
|
||||
bool modified_file_time(const std::filesystem::path& p, struct tm&); ///< extention ?
|
||||
|
||||
} // filesystem_ext
|
||||
} // nana
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace nana
|
||||
folderbox(folderbox&&) = delete;
|
||||
folderbox& operator=(folderbox&&) = delete;
|
||||
public:
|
||||
using path_type = std::experimental::filesystem::path;
|
||||
using path_type = std::filesystem::path;
|
||||
|
||||
explicit folderbox(window owner = nullptr, const path_type& init_path = {}, std::string title={});
|
||||
~folderbox();
|
||||
|
||||
Reference in New Issue
Block a user