inline nana::filesystem
This commit is contained in:
parent
597f6c05cd
commit
3eee1f76b9
@ -38,6 +38,8 @@
|
||||
#define NANA_USING_STD_FILESYSTEM 0
|
||||
#define NANA_USING_BOOST_FILESYSTEM 0
|
||||
|
||||
#define NANA_FILESYSTEM_FORCE 1
|
||||
|
||||
#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) )
|
||||
|
||||
#undef NANA_USING_NANA_FILESYSTEM
|
||||
@ -132,12 +134,8 @@ namespace std {
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
|
||||
namespace nana { namespace experimental { namespace filesystem
|
||||
{
|
||||
#ifndef CXX_NO_INLINE_NAMESPACE
|
||||
inline namespace v1
|
||||
{
|
||||
#endif
|
||||
namespace nana {
|
||||
namespace filesystem {
|
||||
|
||||
enum class file_type
|
||||
{
|
||||
@ -264,17 +262,21 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
const string_type& native() const;
|
||||
operator string_type() const;
|
||||
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
std::string u8string() const;
|
||||
// std::u16string u16string() const;
|
||||
// std::u32string u32string() const;
|
||||
std::string string() const;
|
||||
|
||||
std::string generic_string() const ;
|
||||
std::wstring generic_wstring() const;
|
||||
std::string generic_u8string() const;
|
||||
// std::u16string generic_u16string() const;
|
||||
// std::u32string generic_u32string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
// std::string u8string() const;
|
||||
// std::u16string u16string() const;
|
||||
// std::u32string u32string() const;
|
||||
|
||||
std::string generic_string() const;
|
||||
|
||||
std::wstring generic_wstring() const;
|
||||
|
||||
// std::string generic_u8string() const;
|
||||
// std::u16string generic_u16string() const;
|
||||
// std::u32string generic_u32string() const;
|
||||
|
||||
path lexically_normal() const;
|
||||
|
||||
@ -424,16 +426,17 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
bool is_directory(const path& p);
|
||||
bool is_directory(const path& p, std::error_code& ec) noexcept;
|
||||
|
||||
inline bool is_regular_file(file_status s) noexcept
|
||||
{
|
||||
return s.type() == file_type::regular;
|
||||
}
|
||||
inline bool is_regular_file(const path& p)
|
||||
{
|
||||
return is_regular_file(status(p));
|
||||
}
|
||||
// bool is_regular_file(const path& p, error_code& ec) noexcept;
|
||||
// Returns: is_regular_file(status(p, ec)).Returns false if an error occurs.
|
||||
inline bool is_regular_file(file_status s) noexcept
|
||||
{
|
||||
return s.type() == file_type::regular;
|
||||
}
|
||||
|
||||
inline bool is_regular_file(const path &p)
|
||||
{
|
||||
return is_regular_file(status(p));
|
||||
}
|
||||
// bool is_regular_file(const path& p, error_code& ec) noexcept; // todo:
|
||||
// Returns: is_regular_file(status(p, ec)).Returns false if an error occurs. // todo:
|
||||
|
||||
inline bool is_empty(const path& p)
|
||||
{
|
||||
@ -497,38 +500,34 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
}
|
||||
}
|
||||
|
||||
return index ? path.substr(0, index + 1) : std::basic_string<CharType>();
|
||||
}
|
||||
#ifndef CXX_NO_INLINE_NAMESPACE
|
||||
} //end namespace v1
|
||||
#endif
|
||||
} //end namespace filesystem
|
||||
} //end namespace experimental
|
||||
return index ? path.substr(0, index + 1) : std::basic_string<CharType>();
|
||||
}
|
||||
|
||||
//namespace filesystem = experimental::filesystem;
|
||||
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);
|
||||
|
||||
path weakly_canonical(const path& p);
|
||||
path weakly_canonical(const path& p, std::error_code& err);
|
||||
|
||||
bool exists( file_status s ) noexcept;
|
||||
bool exists( const path& p );
|
||||
bool exists( const path& p, std::error_code& ec ) noexcept;
|
||||
} //end namespace filesystem
|
||||
} //end namespace nana
|
||||
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
|
||||
# ifdef CXX_NO_INLINE_NAMESPACE
|
||||
using namespace nana::experimental::filesystem;
|
||||
# else
|
||||
using namespace nana::experimental::filesystem::v1;
|
||||
# endif
|
||||
|
||||
} // filesystem
|
||||
} // experimental
|
||||
|
||||
namespace filesystem {
|
||||
using namespace std::experimental::filesystem;
|
||||
|
||||
#if defined(NANA_FILESYSTEM_FORCE) || \
|
||||
(defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
|
||||
path absolute(const path& p);
|
||||
path absolute(const path& p, std::error_code& err);
|
||||
namespace std
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
inline namespace nana_filesystem
|
||||
{
|
||||
using namespace ::nana::filesystem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
path canonical(const path& p);
|
||||
path canonical(const path& p, std::error_code& err);
|
||||
|
@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file nana\filesystem\filesystem_ext.hpp
|
||||
* @autor by Ariel Vina-Rodriguez:
|
||||
* @autor Ariel Vina-Rodriguez:
|
||||
* @brief Some convenient extensions to the filesystem library.
|
||||
*
|
||||
*/
|
||||
@ -35,16 +35,6 @@ namespace filesystem_ext
|
||||
|
||||
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::filesystem::path& p)
|
||||
{
|
||||
#if NANA_USING_BOOST_FILESYSTEM
|
||||
return nana::to_utf8(p.generic_wstring());
|
||||
#else
|
||||
return p.generic_u8string();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool is_directory(const std::filesystem::directory_entry& dir) noexcept
|
||||
{
|
||||
return is_directory(dir.status());
|
||||
@ -57,10 +47,10 @@ class directory_only_iterator : public std::filesystem::directory_iterator
|
||||
|
||||
directory_only_iterator& find_first()
|
||||
{
|
||||
auto end = directory_only_iterator{};
|
||||
directory_only_iterator end{};
|
||||
while (*this != end)
|
||||
{
|
||||
if (is_directory((**this).status()))
|
||||
if (is_directory((*(*this)).status()))
|
||||
return *this;
|
||||
this->directory_iterator::operator++();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/**
|
||||
* A ISO C++ FileSystem Implementation
|
||||
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
@ -14,6 +14,7 @@
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <nana/config.hpp>
|
||||
#ifdef _nana_std_put_time
|
||||
@ -150,14 +151,11 @@ namespace nana
|
||||
|
||||
#if NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
namespace nana_fs = nana::experimental::filesystem;
|
||||
|
||||
namespace nana { namespace experimental { namespace filesystem
|
||||
{
|
||||
#ifndef CXX_NO_INLINE_NAMESPACE
|
||||
inline namespace v1 {
|
||||
#endif
|
||||
|
||||
namespace nana_fs = nana::filesystem;
|
||||
namespace nana
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
//class filesystem_error
|
||||
filesystem_error::filesystem_error(const std::string& msg, std::error_code err)
|
||||
: std::system_error(err, msg)
|
||||
@ -667,7 +665,7 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
}
|
||||
|
||||
//class directory_entry
|
||||
directory_entry::directory_entry(const nana_fs::path& p)
|
||||
directory_entry::directory_entry(const filesystem::path& p)
|
||||
:path_{ p }
|
||||
{}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user