From 6225c40775d1529f7c153c7f07c897296852d7af Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 14 Sep 2016 16:21:07 +0200 Subject: [PATCH] Globbing for tindex on Windows --- kernels/tindex/TIndexKernel.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kernels/tindex/TIndexKernel.cpp b/kernels/tindex/TIndexKernel.cpp index 19777be752..84e54709cd 100644 --- a/kernels/tindex/TIndexKernel.cpp +++ b/kernels/tindex/TIndexKernel.cpp @@ -37,6 +37,8 @@ #ifndef WIN32 #include #include +#else +#include #endif #include @@ -194,6 +196,30 @@ StringList TIndexKernel::glob(std::string& path) filenames.push_back(filename); } globfree(&glob_result); +#else + WIN32_FIND_DATA ffd; + HANDLE handle = FindFirstFile(path.c_str(), &ffd); + + if (INVALID_HANDLE_VALUE == handle) + return filenames; + + size_t found = path.find_last_of("/\\"); + std::string dir = path.substr(0, found); + + if (m_absPath) + { + TCHAR full_dir[4192] = TEXT(""); + GetFullPathName(dir.c_str(), 4192, full_dir, NULL); + dir = full_dir; + } + + do + { + std::string filename = dir + "\\" + ffd.cFileName; + filenames.push_back(filename); + } while (FindNextFile(handle, &ffd) != 0); + + FindClose(handle); #endif return filenames;