mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 21:55:57 +00:00
Ask FindFirstFileW for the reparse tag only when the path is a reparse point
plat_fs_kind served every path through FindFirstFileW, which fails on a path with a trailing separator and reads wildcards. GetFileAttributesW decides again, as before; only reparse points need the find data's tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d3f403ecf6
commit
6d31b157a0
1 file changed
+7
-2
@@ -892,9 +892,14 @@ static int fs_kind_of(const WIN32_FIND_DATAW *fd) {
|
||||
int plat_fs_kind(const char *path) {
|
||||
wchar_t w[WPATH];
|
||||
if (!widen(path, w, WPATH)) return PLAT_FS_MISSING;
|
||||
DWORD a = GetFileAttributesW(w);
|
||||
if (a == INVALID_FILE_ATTRIBUTES) return PLAT_FS_MISSING;
|
||||
if (!(a & FILE_ATTRIBUTE_REPARSE_POINT)) return a & FILE_ATTRIBUTE_DIRECTORY ? PLAT_FS_DIR : PLAT_FS_FILE;
|
||||
// the reparse tag comes with the find data only; FindFirstFileW is asked only here, since it fails on a path
|
||||
// with a trailing separator and reads wildcards
|
||||
WIN32_FIND_DATAW fd;
|
||||
HANDLE h = FindFirstFileW(w, &fd); // the reparse tag comes with the find data only
|
||||
if (h == INVALID_HANDLE_VALUE) return PLAT_FS_MISSING;
|
||||
HANDLE h = FindFirstFileW(w, &fd);
|
||||
if (h == INVALID_HANDLE_VALUE) return PLAT_FS_LINK;
|
||||
FindClose(h);
|
||||
return fs_kind_of(&fd);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user