From ebf0b5e3603a6ac79123d52c11aed5a8869e8ba1 Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Fri, 18 Jan 2013 20:07:41 +0000 Subject: 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 --- cpp/src/qpid/sys/windows/FileSysDir.cpp | 39 +++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'cpp/src/qpid/sys/windows/FileSysDir.cpp') 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 #include #include +#include +#include -#include -#include - -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 -- cgit v1.2.1