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
#if defined(_MSC_VER)
# undef STD_FILESYSTEM_NOT_SUPPORTED
# 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
# 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)

View File

@ -53,18 +53,21 @@ class directory_only_iterator : public std::experimental::filesystem::directory_
return *this;
}
public:
directory_only_iterator(){}
template <class... Arg>
directory_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
{
find_first();
}
directory_only_iterator( ) {}
directory_only_iterator& operator++()
{
this->DI::operator++();
return find_first();
}
};
inline directory_only_iterator begin(directory_only_iterator iter) noexcept
{
return iter;
@ -87,12 +90,14 @@ class regular_file_only_iterator : public std::experimental::filesystem::directo
return (*this);
}
public:
regular_file_only_iterator() : DI() {}
template <class... Arg>
regular_file_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
{
find_first();
}
regular_file_only_iterator() : DI() {}
regular_file_only_iterator& 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
{
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)