From 2c869433aad96fab0e7640a2ac7397653b3bdefa Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 10 Sep 2017 06:32:34 -0400 Subject: Well, it compiles --- src/lib/utils/filesystem.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++- src/scripts/ci/travis.yml | 5 ----- 2 files changed, 51 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp index 36e1f5446..8c899dc9b 100644 --- a/src/lib/utils/filesystem.cpp +++ b/src/lib/utils/filesystem.cpp @@ -1,5 +1,5 @@ /* -* (C) 2015 Jack Lloyd +* (C) 2015,2017 Jack Lloyd * (C) 2015 Simon Warta (Kullo GmbH) * * Botan is released under the Simplified BSD License (see license.txt) @@ -20,6 +20,12 @@ #include #include #include +#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) + #define NOMINMAX 1 + #define _WINSOCKAPI_ // stop windows.h including winsock.h + #include + #include + #include #endif namespace Botan { @@ -48,7 +54,9 @@ std::vector impl_stl_filesystem(const std::string& dir) return out; } + #elif defined(BOTAN_HAS_BOOST_FILESYSTEM) + std::vector impl_boost_filesystem(const std::string& dir_path) { namespace fs = boost::filesystem; @@ -65,6 +73,7 @@ std::vector impl_boost_filesystem(const std::string& dir_path) return out; } + #elif defined(BOTAN_TARGET_OS_HAS_READDIR) std::vector impl_readdir(const std::string& dir_path) { @@ -103,6 +112,45 @@ std::vector impl_readdir(const std::string& dir_path) return out; } + +#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) + +std::vector impl_win32(const std::string& dir_path) + { + std::vector out; + std::deque dir_list; + dir_list.push_back(dir_path); + + while(!dir_list.empty()) + { + const std::string cur_path = dir_list[0]; + dir_list.pop_front(); + + WIN32_FIND_DATA find_data; + HANDLE dir = ::FindFirstFile(cur_path.c_str(), &find_data); + + if(dir != INVALID_HANDLE_VALUE) + { + do + { + const std::string filename = find_data.cFileName; + if(filename == "." || filename == "..") + continue; + const std::string full_path = cur_path + "/" + filename; + + if(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + dir_list.push_back(full_path); + else if(find_data.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) + out.push_back(full_path); + } + while(::FindNextFile(dir, &find_data)); + } + + ::FindClose(dir); + } + + return out; +} #endif } @@ -117,6 +165,8 @@ std::vector get_files_recursive(const std::string& dir) files = impl_boost_filesystem(dir); #elif defined(BOTAN_TARGET_OS_HAS_READDIR) files = impl_readdir(dir); +#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) + files = impl_win32(dir); #else BOTAN_UNUSED(dir); throw No_Filesystem_Access(); diff --git a/src/scripts/ci/travis.yml b/src/scripts/ci/travis.yml index cdd5192b6..ad5f34b9b 100644 --- a/src/scripts/ci/travis.yml +++ b/src/scripts/ci/travis.yml @@ -41,11 +41,6 @@ env: - BUILD_MODE="fuzzers" matrix: - # Ignore some problem builds for now - allow_failures: - - os: linux - env: BUILD_MODE="cross-win32" - exclude: # Skip GCC on OS X entirely - os: osx -- cgit v1.2.3 From 359732815e61fe61cfc1f34698254e44137120e7 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 10 Sep 2017 07:16:50 -0400 Subject: Make it actually work Weirdly Wine at least does not set FILE_ATTRIBUTE_NORMAL on the files, instead sets FILE_ATTRIBUTE_ARCHIVE. ?? I have no idea what that's about. --- src/lib/utils/filesystem.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp index 8c899dc9b..fd4aee1f0 100644 --- a/src/lib/utils/filesystem.cpp +++ b/src/lib/utils/filesystem.cpp @@ -127,7 +127,7 @@ std::vector impl_win32(const std::string& dir_path) dir_list.pop_front(); WIN32_FIND_DATA find_data; - HANDLE dir = ::FindFirstFile(cur_path.c_str(), &find_data); + HANDLE dir = ::FindFirstFile((cur_path + "/*").c_str(), &find_data); if(dir != INVALID_HANDLE_VALUE) { @@ -139,9 +139,13 @@ std::vector impl_win32(const std::string& dir_path) const std::string full_path = cur_path + "/" + filename; if(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { dir_list.push_back(full_path); - else if(find_data.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) + } + else + { out.push_back(full_path); + } } while(::FindNextFile(dir, &find_data)); } -- cgit v1.2.3