std.exp.filesystem for vc2013

This commit is contained in:
Jinhao 2016-06-21 09:30:15 +08:00
parent 705fca5232
commit d04776216b
3 changed files with 44 additions and 34 deletions

View File

@ -43,14 +43,19 @@
//C++ language //C++ language
#if defined(_MSC_VER) #if defined(_MSC_VER)
# undef STD_FILESYSTEM_NOT_SUPPORTED
# if (_MSC_VER < 1900) # if (_MSC_VER < 1900)
# //About std.experimental.filesystem.
# //Through VC2013 has provided <filesystem>, 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 # //Nana defines some macros for lack of support of keywords
# define _ALLOW_KEYWORD_MACROS # define _ALLOW_KEYWORD_MACROS
# #
# define CXX_NO_INLINE_NAMESPACE //no support of C++11 inline namespace until Visual C++ 2015 # 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 noexcept //no support of noexcept until Visual C++ 2015
# define constexpr //no support of constexpr until Visual C++ 2015 # define constexpr //no support of constexpr until Visual C++ 2015
# else
# undef STD_FILESYSTEM_NOT_SUPPORTED
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6) # if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)

View File

@ -53,18 +53,21 @@ class directory_only_iterator : public std::experimental::filesystem::directory_
return *this; return *this;
} }
public: public:
directory_only_iterator(){}
template <class... Arg> template <class... Arg>
directory_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...) directory_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
{ {
find_first(); find_first();
} }
directory_only_iterator( ) {}
directory_only_iterator& operator++() directory_only_iterator& operator++()
{ {
this->DI::operator++(); this->DI::operator++();
return find_first(); return find_first();
} }
}; };
inline directory_only_iterator begin(directory_only_iterator iter) noexcept inline directory_only_iterator begin(directory_only_iterator iter) noexcept
{ {
return iter; return iter;
@ -87,12 +90,14 @@ class regular_file_only_iterator : public std::experimental::filesystem::directo
return (*this); return (*this);
} }
public: public:
regular_file_only_iterator() : DI() {}
template <class... Arg> template <class... Arg>
regular_file_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...) regular_file_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
{ {
find_first(); find_first();
} }
regular_file_only_iterator() : DI() {}
regular_file_only_iterator& operator++() regular_file_only_iterator& operator++()
{ {
this->DI::operator++(); this->DI::operator++();
@ -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 inline std::string pretty_file_size(const std::experimental::filesystem::path& path) // todo: move to .cpp
{ {
try { 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" }; const char * ustr[] = { " KB", " MB", " GB", " TB" };
std::stringstream ss; std::stringstream ss;
if (bytes < 1024) if (bytes < 1024)