remove filesystem_selector
This commit is contained in:
parent
c65247b413
commit
1845b41019
@ -59,7 +59,7 @@
|
||||
|
||||
# define constexpr const //no support of constexpr until Visual C++ 2015 ? const ??
|
||||
# else
|
||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||
# endif
|
||||
#elif defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
//# The library maybe available in the std library in use or from Boost(almost compatible)
|
||||
//# http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
//# or you can choose to use the(partial, but functional) implementation provided by nana.
|
||||
//# If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
//# If you include the file <nana/filesystem/filesystem.hpp>
|
||||
//# the selected option will be set by nana into std::experimental::filesystem
|
||||
//# By default Nana will try to use the STD.If not available will try
|
||||
//# to use boost if available.Nana own implementation will be use only none of them are available.
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file nana/filesystem/filesystem.hpp
|
||||
* @author Jinhao, conributed: Ariel Vina-Rodriguez
|
||||
* @author Ariel Vina-Rodriguez, Jinhao
|
||||
* @brief Mimic std::experimental::filesystem::v1 (boost v3)
|
||||
* and need VC2015 or a C++11 compiler. With a few correction can be compiler by VC2013
|
||||
*/
|
||||
@ -29,12 +29,54 @@
|
||||
|
||||
#ifndef NANA_FILESYSTEM_HPP
|
||||
#define NANA_FILESYSTEM_HPP
|
||||
|
||||
//#undef NANA_USING_NANA_FILESYSTEM
|
||||
#if NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
#include <nana/push_ignore_diagnostic>
|
||||
|
||||
//Filesystem Selection
|
||||
#include <nana/config.hpp>
|
||||
|
||||
#if defined(NANA_USING_NANA_FILESYSTEM) || defined(NANA_USING_STD_FILESYSTEM) || defined(NANA_USING_BOOST_FILESYSTEM)
|
||||
#undef NANA_USING_NANA_FILESYSTEM
|
||||
#undef NANA_USING_STD_FILESYSTEM
|
||||
#undef NANA_USING_BOOST_FILESYSTEM
|
||||
#endif
|
||||
|
||||
#define NANA_USING_NANA_FILESYSTEM 0
|
||||
#define NANA_USING_STD_FILESYSTEM 0
|
||||
#define NANA_USING_BOOST_FILESYSTEM 0
|
||||
|
||||
#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
|
||||
#define NANA_USING_NANA_FILESYSTEM 1
|
||||
|
||||
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
|
||||
|
||||
#undef NANA_USING_BOOST_FILESYSTEM
|
||||
#define NANA_USING_BOOST_FILESYSTEM 1
|
||||
# include <boost/filesystem.hpp>
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
using namespace boost::filesystem;
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#else
|
||||
|
||||
#undef NANA_USING_STD_FILESYSTEM
|
||||
#define NANA_USING_STD_FILESYSTEM 1
|
||||
# include <experimental/filesystem>
|
||||
#endif
|
||||
|
||||
#ifndef __cpp_lib_experimental_filesystem
|
||||
# define __cpp_lib_experimental_filesystem 1
|
||||
#endif
|
||||
|
||||
#if NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <iterator>
|
||||
@ -413,6 +455,21 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
//namespace filesystem = experimental::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
|
||||
} // std
|
||||
|
||||
#endif //NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
#include <nana/pop_ignore_diagnostic>
|
||||
#endif
|
||||
#endif
|
||||
#endif //NANA_FILESYSTEM_HPP
|
||||
|
||||
@ -15,10 +15,7 @@
|
||||
#ifndef NANA_FILESYSTEM_EXT_HPP
|
||||
#define NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <nana/filesystem/filesystem_selector.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@ -45,7 +42,8 @@ inline bool is_directory(const std::experimental::filesystem::directory_entry& d
|
||||
//template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
|
||||
class directory_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||
{
|
||||
using DI = std::experimental::filesystem::directory_iterator;
|
||||
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||
|
||||
directory_only_iterator& find_first()
|
||||
{
|
||||
auto end = directory_only_iterator{};
|
||||
@ -53,22 +51,22 @@ class directory_only_iterator : public std::experimental::filesystem::directory_
|
||||
{
|
||||
if (is_directory((**this).status()))
|
||||
return *this;
|
||||
this->DI::operator++();
|
||||
this->directory_iterator::operator++();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
directory_only_iterator(){}
|
||||
directory_only_iterator() = default;
|
||||
|
||||
template <class... Arg>
|
||||
directory_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
|
||||
template <typename Arg, typename... Args>
|
||||
directory_only_iterator(Arg&& arg, Args&&... args) : directory_iterator(arg, std::forward<Args>(args)...)
|
||||
{
|
||||
find_first();
|
||||
}
|
||||
|
||||
directory_only_iterator& operator++()
|
||||
{
|
||||
this->DI::operator++();
|
||||
this->directory_iterator::operator++();
|
||||
return find_first();
|
||||
}
|
||||
};
|
||||
@ -86,25 +84,25 @@ 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
|
||||
{
|
||||
using DI = std::experimental::filesystem::directory_iterator;
|
||||
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||
regular_file_only_iterator& find_first()
|
||||
{
|
||||
while(( (*this) != DI{}) && !is_regular_file((**this).status()))
|
||||
this->DI::operator++();
|
||||
while (((*this) != directory_iterator{}) && !is_regular_file((**this).status()))
|
||||
this->directory_iterator::operator++();
|
||||
return (*this);
|
||||
}
|
||||
public:
|
||||
regular_file_only_iterator() : DI() {}
|
||||
regular_file_only_iterator() = default;
|
||||
|
||||
template <class... Arg>
|
||||
regular_file_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
|
||||
template <typename Arg, typename... Args>
|
||||
regular_file_only_iterator(Arg&& arg, Args&&... args) : directory_iterator(std::forward<Arg>(arg), std::forward<Args>(args)...)
|
||||
{
|
||||
find_first();
|
||||
}
|
||||
|
||||
regular_file_only_iterator& operator++()
|
||||
{
|
||||
this->DI::operator++();
|
||||
this->directory_iterator::operator++();
|
||||
return find_first();
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
/**
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 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_selector.hpp
|
||||
* @autor by Ariel Vina-Rodriguez:
|
||||
* @brief A "ISO C++" filesystem Implementation selector
|
||||
*
|
||||
* The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional.
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
* This is not a workaround, but an user option.
|
||||
* The library maybe available in the std library in use or from Boost(almost compatible)
|
||||
* http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
* or you can choose to use the(partial, but functional) implementation provided by nana.
|
||||
* If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
* the selected option will be set by nana into std::experimental::filesystem
|
||||
* By default Nana will try to use the STD. If not available will try
|
||||
* to use boost if available. Nana own implementation will be use only if none of them are available.
|
||||
* nana Now mimic std::experimental::filesystem::v1 (boost v3)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NANA_FILESYSTEM_SELECTOR
|
||||
#define NANA_FILESYSTEM_SELECTOR
|
||||
|
||||
#include <nana/config.hpp>
|
||||
|
||||
#define NANA_USING_NANA_FILESYSTEM false
|
||||
#define NANA_USING_STD_FILESYSTEM false
|
||||
#define NANA_USING_BOOST_FILESYSTEM false
|
||||
|
||||
#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
|
||||
#define NANA_USING_NANA_FILESYSTEM true
|
||||
# include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
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
|
||||
} // std
|
||||
|
||||
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
|
||||
|
||||
#undef NANA_USING_BOOST_FILESYSTEM
|
||||
#define NANA_USING_BOOST_FILESYSTEM true
|
||||
# include <boost/filesystem.hpp>
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
using namespace boost::filesystem;
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#else
|
||||
|
||||
#undef NANA_USING_STD_FILESYSTEM
|
||||
#define NANA_USING_STD_FILESYSTEM true
|
||||
# include <experimental/filesystem>
|
||||
#endif
|
||||
|
||||
#ifndef __cpp_lib_experimental_filesystem
|
||||
# define __cpp_lib_experimental_filesystem 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif // NANA_FILESYSTEM_SELECTOR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -13,6 +13,9 @@
|
||||
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iomanip> //put_time
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
|
||||
@ -102,7 +105,13 @@ namespace nana
|
||||
|
||||
if (ftime == ((fs::file_time_type::min)())) return{};
|
||||
|
||||
std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||
//std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||
|
||||
//A workaround for VC2013
|
||||
using time_point = decltype(ftime);
|
||||
|
||||
auto cftime = time_point::clock::to_time_t(ftime);
|
||||
|
||||
std::stringstream tm;
|
||||
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||
return tm.str();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user