aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/filesystem.cpp
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-16 18:39:50 +0200
committerSimon Warta <[email protected]>2015-07-16 19:04:34 +0200
commit748ae07caf2445f7b75f5c96ae674c6de0b0610a (patch)
treebae6bc6de24dbdfd732c1734c78aeae566837ece /src/lib/utils/filesystem.cpp
parent2ea885ffe9f44fada457b9cc8e169418c57f1bdb (diff)
Add MSVC stl filesystem implementation
Closes #199
Diffstat (limited to 'src/lib/utils/filesystem.cpp')
-rw-r--r--src/lib/utils/filesystem.cpp33
1 files changed, 30 insertions, 3 deletions
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);