diff options
Diffstat (limited to 'cpp/src/qpid/sys/windows/FileSysDir.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/windows/FileSysDir.cpp | 39 |
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 |
