16 #ifndef SERIALBOX_CORE_FILESYSTEM_H 17 #define SERIALBOX_CORE_FILESYSTEM_H 19 #include "serialbox/core/Config.h" 21 #ifdef SERIALBOX_USE_STD_EXPERIMENTAL_FILESYSTEM 22 #include <experimental/filesystem> 23 namespace filesystem = std::experimental::filesystem;
28 inline std::uintmax_t remove_all(
const filesystem::path& p, std::error_code& ec) noexcept {
29 auto fs = filesystem::symlink_status(p, ec);
31 if(ec.value() == 0 && fs.type() == filesystem::file_type::directory)
32 for(filesystem::directory_iterator d(p, ec), end; ec.value() == 0 && d != end; ++d)
33 count += serialbox::remove_all(d->path(), ec);
36 return filesystem::remove(p, ec) ? ++count : -1;
39 inline std::uintmax_t remove_all(
const filesystem::path& p) {
41 bool result = serialbox::remove_all(p, ec);
43 _GLIBCXX_THROW_OR_ABORT(filesystem::filesystem_error(
"cannot remove all", p, ec));
47 #elif SERIALBOX_USE_BOOST_FILESYSTEM 48 #include <boost/filesystem.hpp> 49 namespace filesystem = boost::filesystem;
52 inline boost::uintmax_t remove_all(
const filesystem::path& p) {
return filesystem::remove_all(p); }
54 inline boost::uintmax_t remove_all(
const filesystem::path& p,
55 boost::system::error_code& ec) BOOST_NOEXCEPT {
56 return filesystem::remove_all(p, ec);
60 #error "Filesystem selection is not properly configured." Namespace of the serialbox library.