aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-17 09:42:59 -0500
committerJack Lloyd <[email protected]>2019-01-17 09:42:59 -0500
commitaff8cc8a7a5e22e3fedeae7ca82b63d4744ac82c (patch)
tree9218e48a50aec107b18672dda88e5d8b74984519 /src
parentdc799b9eb8cb2970541c283dc285f3cd282cb119 (diff)
Remove use of std::filesystem / boost::filesystem
Boost doesn't buy us anything here since we need to maintain Win32 and POSIX implementations for non-Boost builds, and Boost only supports those two APIs anyway. MSVC's implementation of std::filesystem does not help for similar reasons, as we have to maintain a Win32 version for MinGW.
Diffstat (limited to 'src')
-rw-r--r--src/build-data/os/windows.txt1
-rw-r--r--src/lib/utils/boost/info.txt3
-rw-r--r--src/lib/utils/filesystem.cpp74
3 files changed, 8 insertions, 70 deletions
diff --git a/src/build-data/os/windows.txt b/src/build-data/os/windows.txt
index 209df6e03..8eab164df 100644
--- a/src/build-data/os/windows.txt
+++ b/src/build-data/os/windows.txt
@@ -29,7 +29,6 @@ rtlgenrandom
rtlsecurezeromemory
virtual_lock
-stl_filesystem_msvc
threads
filesystem
diff --git a/src/lib/utils/boost/info.txt b/src/lib/utils/boost/info.txt
index d54421147..6330cbafd 100644
--- a/src/lib/utils/boost/info.txt
+++ b/src/lib/utils/boost/info.txt
@@ -1,10 +1,9 @@
<defines>
-BOOST_FILESYSTEM -> 20131228
BOOST_ASIO -> 20131228
</defines>
load_on vendor
<libs>
-all -> boost_system,boost_filesystem
+all -> boost_system
</libs>
diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp
index 053c91e70..3072a304f 100644
--- a/src/lib/utils/filesystem.cpp
+++ b/src/lib/utils/filesystem.cpp
@@ -1,5 +1,5 @@
/*
-* (C) 2015,2017 Jack Lloyd
+* (C) 2015,2017,2019 Jack Lloyd
* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
@@ -8,77 +8,25 @@
#include <botan/exceptn.h>
#include <botan/internal/filesystem.h>
#include <algorithm>
+#include <deque>
+#include <memory>
-#if defined(BOTAN_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) && defined(BOTAN_BUILD_COMPILER_IS_MSVC)
- #include <filesystem>
-#elif defined(BOTAN_HAS_BOOST_FILESYSTEM)
- #include <boost/filesystem.hpp>
-#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
+#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
- #include <deque>
- #include <memory>
#include <functional>
#elif defined(BOTAN_TARGET_OS_HAS_WIN32)
#define NOMINMAX 1
#define _WINSOCKAPI_ // stop windows.h including winsock.h
#include <windows.h>
- #include <deque>
- #include <memory>
#endif
namespace Botan {
namespace {
-#if defined(BOTAN_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) && defined(BOTAN_BUILD_COMPILER_IS_MSVC)
-std::vector<std::string> impl_stl_filesystem(const std::string& dir)
- {
-#if (_MSVC_LANG >= 201703L)
- using namespace std::filesystem;
-#else
- using namespace std::tr2::sys;
-#endif
-
- std::vector<std::string> out;
-
- path p(dir);
-
- if(is_directory(p))
- {
- for(recursive_directory_iterator itr(p), end; itr != end; ++itr)
- {
- if(is_regular_file(itr->path()))
- {
- out.push_back(itr->path().string());
- }
- }
- }
-
- return out;
- }
-
-#elif defined(BOTAN_HAS_BOOST_FILESYSTEM)
-
-std::vector<std::string> impl_boost_filesystem(const std::string& dir_path)
-{
- namespace fs = boost::filesystem;
-
- std::vector<std::string> out;
-
- for(fs::recursive_directory_iterator dir(dir_path), end; dir != end; ++dir)
- {
- if(fs::is_regular_file(dir->path()))
- {
- out.push_back(dir->path().string());
- }
- }
-
- return out;
-}
-
-#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
+#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
std::vector<std::string> impl_readdir(const std::string& dir_path)
{
@@ -166,11 +114,7 @@ std::vector<std::string> impl_win32(const std::string& dir_path)
bool has_filesystem_impl()
{
-#if defined(BOTAN_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) && defined(BOTAN_BUILD_COMPILER_IS_MSVC)
- return true;
-#elif defined(BOTAN_HAS_BOOST_FILESYSTEM)
- return true;
-#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
+#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
return true;
#elif defined(BOTAN_TARGET_OS_HAS_WIN32)
return true;
@@ -183,11 +127,7 @@ std::vector<std::string> get_files_recursive(const std::string& dir)
{
std::vector<std::string> files;
-#if defined(BOTAN_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) && defined(BOTAN_BUILD_COMPILER_IS_MSVC)
- files = impl_stl_filesystem(dir);
-#elif defined(BOTAN_HAS_BOOST_FILESYSTEM)
- files = impl_boost_filesystem(dir);
-#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
+#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
files = impl_readdir(dir);
#elif defined(BOTAN_TARGET_OS_HAS_WIN32)
files = impl_win32(dir);