Skip to content

Commit 9afcc00

Browse files
committed
Disk (Windows): don't rely on env vars
1 parent cd783d1 commit 9afcc00

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/detection/disk/disk_windows.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <windows.h>
66
#include <winioctl.h>
7-
#include <assert.h>
87

98
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
109
{
@@ -18,8 +17,9 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
1817
// For cross-platform portability; used by `presets/examples/13.jsonc`
1918
if (__builtin_expect(options->folders.length == 1 && options->folders.chars[0] == '/', 0))
2019
{
21-
ffStrbufSetS(&options->folders, getenv("SystemDrive"));
22-
ffStrbufEnsureEndsWithC(&options->folders, '\\');
20+
wchar_t path[MAX_PATH + 1];
21+
GetSystemWindowsDirectoryW(path, sizeof(path) / sizeof(*path));
22+
ffStrbufSetF(&options->folders, "%c:\\", (char) path[0]);
2323
}
2424

2525
for(uint32_t i = 0; i < length; i++)

0 commit comments

Comments
 (0)