diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index 2dc4c5f2..d9e9fef6 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -43,14 +43,19 @@ //C++ language #if defined(_MSC_VER) -# undef STD_FILESYSTEM_NOT_SUPPORTED # if (_MSC_VER < 1900) +# //About std.experimental.filesystem. +# //Through VC2013 has provided , but all the names are given in namespace std. It's hard to alias these names into std::experimental, +# //So Nana use nana.filesystem implement instead for VC2013 +# # //Nana defines some macros for lack of support of keywords # define _ALLOW_KEYWORD_MACROS # # define CXX_NO_INLINE_NAMESPACE //no support of C++11 inline namespace until Visual C++ 2015 # define noexcept //no support of noexcept until Visual C++ 2015 # define constexpr //no support of constexpr until Visual C++ 2015 +# else +# undef STD_FILESYSTEM_NOT_SUPPORTED # endif #elif defined(__GNUC__) # if (__GNUC__ == 4 && __GNUC_MINOR__ < 6) diff --git a/include/nana/filesystem/filesystem_ext.hpp b/include/nana/filesystem/filesystem_ext.hpp index ef561665..feb68fa9 100644 --- a/include/nana/filesystem/filesystem_ext.hpp +++ b/include/nana/filesystem/filesystem_ext.hpp @@ -42,29 +42,32 @@ class directory_only_iterator : public std::experimental::filesystem::directory_ { using DI = std::experimental::filesystem::directory_iterator; directory_only_iterator& find_first() - { - auto end = directory_only_iterator{}; - while (*this != end) - { - if (is_directory((**this).status())) - return *this; - this->DI::operator++(); - } - return *this; - } + { + auto end = directory_only_iterator{}; + while (*this != end) + { + if (is_directory((**this).status())) + return *this; + this->DI::operator++(); + } + return *this; + } public: - template - directory_only_iterator(Arg&&... arg ): DI(std::forward(arg)...) - { - find_first(); - } - directory_only_iterator( ) {} + directory_only_iterator(){} + + template + directory_only_iterator(Arg&&... arg ): DI(std::forward(arg)...) + { + find_first(); + } + directory_only_iterator& operator++() { this->DI::operator++(); return find_first(); } }; + inline directory_only_iterator begin(directory_only_iterator iter) noexcept { return iter; @@ -81,23 +84,25 @@ class regular_file_only_iterator : public std::experimental::filesystem::directo { using DI = std::experimental::filesystem::directory_iterator; regular_file_only_iterator& find_first() - { - while(( (*this) != DI{}) && !is_regular_file((**this).status())) - this->DI::operator++(); - return (*this); - } + { + while(( (*this) != DI{}) && !is_regular_file((**this).status())) + this->DI::operator++(); + return (*this); + } public: - template - regular_file_only_iterator(Arg&&... arg ): DI(std::forward(arg)...) - { - find_first(); - } regular_file_only_iterator() : DI() {} - regular_file_only_iterator& operator++() - { - this->DI::operator++(); - return find_first(); - } + + template + regular_file_only_iterator(Arg&&... arg ): DI(std::forward(arg)...) + { + find_first(); + } + + regular_file_only_iterator& operator++() + { + this->DI::operator++(); + return find_first(); + } }; inline regular_file_only_iterator begin(regular_file_only_iterator iter) noexcept @@ -113,7 +118,7 @@ inline regular_file_only_iterator end(const regular_file_only_iterator&) noexcep inline std::string pretty_file_size(const std::experimental::filesystem::path& path) // todo: move to .cpp { try { - std::size_t bytes = std::experimental::filesystem::file_size ( path ); + auto bytes = std::experimental::filesystem::file_size ( path ); const char * ustr[] = { " KB", " MB", " GB", " TB" }; std::stringstream ss; if (bytes < 1024) diff --git a/include/nana/filesystem/filesystem_selector.hpp b/include/nana/filesystem/filesystem_selector.hpp index b0d3ae3a..e0b084b4 100644 --- a/include/nana/filesystem/filesystem_selector.hpp +++ b/include/nana/filesystem/filesystem_selector.hpp @@ -61,7 +61,7 @@ namespace std { } // std #else -# include +# include #endif #ifndef __cpp_lib_experimental_filesystem