aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/build-data/os/windows.txt1
-rw-r--r--src/lib/utils/filesystem.cpp33
-rw-r--r--src/lib/utils/filesystem.h1
3 files changed, 32 insertions, 3 deletions
diff --git a/src/build-data/os/windows.txt b/src/build-data/os/windows.txt
index b72ef0768..c34f2e7ab 100644
--- a/src/build-data/os/windows.txt
+++ b/src/build-data/os/windows.txt
@@ -18,6 +18,7 @@ loadlibrary
query_perf_counter
virtual_lock
rtlsecurezeromemory
+stl_filesystem_msvc
</target_features>
<aliases>
diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp
index 0a31dec7a..950d4d4e2 100644
--- a/src/lib/utils/filesystem.cpp
+++ b/src/lib/utils/filesystem.cpp
@@ -1,5 +1,6 @@
/*
* (C) 2015 Jack Lloyd
+* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
@@ -8,7 +9,9 @@
#include <botan/internal/filesystem.h>
#include <algorithm>
-#if defined(BOTAN_HAS_BOOST_FILESYSTEM)
+#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_READDIR)
#include <sys/types.h>
@@ -23,7 +26,29 @@ namespace Botan {
namespace {
-#if defined(BOTAN_HAS_BOOST_FILESYSTEM)
+#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)
+ {
+ using namespace std::tr2::sys;
+
+ 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;
@@ -86,7 +111,9 @@ std::vector<std::string> get_files_recursive(const std::string& dir)
{
std::vector<std::string> files;
-#if defined(BOTAN_HAS_BOOST_FILESYSTEM)
+#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_READDIR)
files = impl_readdir(dir);
diff --git a/src/lib/utils/filesystem.h b/src/lib/utils/filesystem.h
index 6f9b5196e..419f94b99 100644
--- a/src/lib/utils/filesystem.h
+++ b/src/lib/utils/filesystem.h
@@ -1,5 +1,6 @@
/*
* (C) 2015 Jack Lloyd
+* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
*/