summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/windows/FileSysDir.cpp
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2013-01-18 20:07:41 +0000
committerCharles E. Rolke <chug@apache.org>2013-01-18 20:07:41 +0000
commitebf0b5e3603a6ac79123d52c11aed5a8869e8ba1 (patch)
treeae93026614ec84cb00baffb32bff4dff6f9b676a /cpp/src/qpid/sys/windows/FileSysDir.cpp
parentd34ab8173f15fd4d247a03859d815da16f0261c2 (diff)
downloadqpid-python-ebf0b5e3603a6ac79123d52c11aed5a8869e8ba1.tar.gz
QPID-4095: New boost filesystem support. This commit removes the requirement for Boost filesystem in Windows.
The code in FileSysDir that used Boost is rewritten to use simple windows native calls instead. Now Boost filesystem is not used at all. All references in CMakeLists.txt are removed. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1435326 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/windows/FileSysDir.cpp')
-rw-r--r--cpp/src/qpid/sys/windows/FileSysDir.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/cpp/src/qpid/sys/windows/FileSysDir.cpp b/cpp/src/qpid/sys/windows/FileSysDir.cpp
index 88a2e62acc..e090747715 100644
--- a/cpp/src/qpid/sys/windows/FileSysDir.cpp
+++ b/cpp/src/qpid/sys/windows/FileSysDir.cpp
@@ -24,11 +24,9 @@
#include <sys/stat.h>
#include <direct.h>
#include <errno.h>
+#include <windows.h>
+#include <strsafe.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
-namespace fs=boost::filesystem;
namespace qpid {
namespace sys {
@@ -56,12 +54,35 @@ void FileSysDir::mkdir(void)
}
void FileSysDir::forEachFile(Callback cb) const {
- fs::directory_iterator dirP(dirPath);
- fs::directory_iterator endItr;
- for (fs::directory_iterator itr (dirP); itr != endItr; ++itr)
- {
- cb(itr->path().string());
+
+ WIN32_FIND_DATAA findFileData;
+ char szDir[MAX_PATH];
+ size_t dirPathLength;
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+
+ // create dirPath+"\*" in szDir
+ StringCchLength (dirPath.c_str(), MAX_PATH, &dirPathLength);
+
+ if (dirPathLength > (MAX_PATH - 3)) {
+ throw Exception ("Directory path is too long: " + dirPath);
}
+
+ StringCchCopy(szDir, MAX_PATH, dirPath.c_str());
+ StringCchCat(szDir, MAX_PATH, TEXT("\\*"));
+
+ // Special work for first file
+ hFind = FindFirstFileA(szDir, &findFileData);
+ if (INVALID_HANDLE_VALUE == hFind) {
+ return;
+ }
+
+ // process everything that isn't a directory
+ do {
+ if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ std::string fileName(findFileData.cFileName);
+ cb(fileName);
+ }
+ } while (FindNextFile(hFind, &findFileData) != 0);
}
}} // namespace qpid::sys