Skip to content

Commit

Permalink
FindExInfoBasic -> FindExInfoStandard to support ancient Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 1, 2020
1 parent aeed852 commit 5482a4c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/libstore/gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@ void LocalStore::removeUnusedLinks(const GCState & state)

WIN32_FIND_DATAW wfd;
std::wstring wlinksDir = pathW(linksDir);
HANDLE hFind = FindFirstFileExW((wlinksDir + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wlinksDir + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when LocalStore::removeUnusedLinks()");
} else {
Expand Down Expand Up @@ -998,7 +1000,9 @@ std::cerr << "LocalStore::collectGarbage" <<std::endl;
dir.reset();
#else
WIN32_FIND_DATAW wfd;
HANDLE hFind = FindFirstFileExW((pathW(realStoreDir) + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((pathW(realStoreDir) + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when collectGarbage '%1%'", realStoreDir);
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ static void canonicalisePathMetaData_(const std::wstring & wpath, const WIN32_FI
// do not follow symlinks?
} else {
WIN32_FIND_DATAW wfd;
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when canonicalisePathMetaData '%1%'", to_bytes(wpath));
} else {
Expand Down
8 changes: 6 additions & 2 deletions src/libstore/optimise-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ LocalStore::InodeHash LocalStore::loadInodeHash()
#else
WIN32_FIND_DATAW wfd;
std::wstring wlinksDir = pathW(linksDir);
HANDLE hFind = FindFirstFileExW((wlinksDir + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wlinksDir + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when LocalStore::loadInodeHash()");
} else {
Expand Down Expand Up @@ -128,7 +130,9 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHa
#else
WIN32_FIND_DATAW wfd;
std::wstring wpath = pathW(path);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when LocalStore::readDirectoryIgnoringInodes()");
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/libutil/archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ static void dump(const Path & path, const std::wstring & wpath, /* the same path
std::map<std::wstring, std::pair<DWORD, uint64_t>> unhacked;

WIN32_FIND_DATAW wfd;
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when dumping nar '%1%'", path);
} else {
Expand Down
8 changes: 6 additions & 2 deletions src/libutil/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ std::cerr << "readDirectory("<<path<<")"<<std::endl;
const std::wstring wpath = pathW(path);

WIN32_FIND_DATAW wfd;
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when readDirectory '%1%'", path);
} else {
Expand Down Expand Up @@ -981,7 +983,9 @@ static void _deletePath(const std::wstring & wpath, const DWORD * pdwFileAttribu
if ((dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
if ((dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
WIN32_FIND_DATAW wfd;
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, NULL, 0);
HANDLE hFind = FindFirstFileExW((wpath + L"\\*").c_str(),
FindExInfoStandard /*from Windows 7/Server 2008 R2: FindExInfoBasic*/,
&wfd, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
throw WinError("FindFirstFileExW when deletePath '%1%'", to_bytes(wpath));
} else {
Expand Down

0 comments on commit 5482a4c

Please sign in to comment.