Skip to content

Commit 39fba21

Browse files
committed
Fix: Make get_space_left on Windows use current_dir instead of process CWD
1 parent 967e2d4 commit 39fba21

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/windows/dir_access_windows.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,14 @@ Error DirAccessWindows::remove(String p_path) {
329329

330330
uint64_t DirAccessWindows::get_space_left() {
331331
uint64_t bytes = 0;
332-
if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) {
332+
333+
String path = fix_path(current_dir);
334+
335+
if (!path.ends_with("\\")) {
336+
path += "\\";
337+
}
338+
339+
if (!GetDiskFreeSpaceExW((LPCWSTR)(path.utf16().get_data()), (PULARGE_INTEGER)&bytes, nullptr, nullptr)) {
333340
return 0;
334341
}
335342

0 commit comments

Comments
 (0)