@joebigelow / wix-1 / commits / 638532e5

Fix up small inaccuracy in logged error message.

When ::GetFileAttributesW returns 0xFFFFFFFF it means 'Invalid File/Folder' So we should return a matching error message. To avoid confusing invalid paths with junctions (in error message) Unfortunately the constant for this is not defined. So just define it here as though it would be. Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>

Bevan Weiss committed Aug 2, 2024 at 22:19 UTC 638532e58ab4c06c35f17421d36ae02ef02ffaf2
1 file changed +13 -1
src/ext/Util/ca/RemoveFoldersEx.cpp
+13 -1
@@ -2,6 +2,12 @@
2
3 #include "precomp.h"
4
5 +// Whilst ::GetFileAttributesW might return FILE_ATTRIBUTE_INVALID for an invalid path, it's not a header defined variable.
6 +// so define it here, but guard it to avoid redefining it if Microsoft change their mind
7 +#ifndef FILE_ATTRIBUTE_INVALID
8 +#define FILE_ATTRIBUTE_INVALID ((DWORD)-1)
9 +#endif
10 +
11 LPCWSTR vcsRemoveFolderExQuery =
12 L"SELECT `RemoveFolderEx`, `Component_`, `Property`, `InstallMode`, `Wix4RemoveFolderEx`.`Condition`, `Component`.`Attributes` "
13 L"FROM `Wix4RemoveFolderEx`,`Component` "
@@ -38,8 +44,14 @@ static HRESULT RecursePath(
44 }
45 #endif
46
41 - // Do NOT follow junctions.
47 DWORD dwAttributes = ::GetFileAttributesW(wzPath);
48 + if (FILE_ATTRIBUTE_INVALID == dwAttributes)
49 + {
50 + WcaLog(LOGMSG_STANDARD, "Path is invalid: %ls", wzPath);
51 + ExitFunction();
52 + }
53 +
54 + // Do NOT follow junctions.
55 if (dwAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
56 {
57 WcaLog(LOGMSG_STANDARD, "Path is a junction; skipping: %ls", wzPath);