From 39fba218bdb31174558eeac972185547d3c00b5d Mon Sep 17 00:00:00 2001 From: moluopro Date: Fri, 25 Jul 2025 17:03:52 +0800 Subject: [PATCH] Fix: Make get_space_left on Windows use current_dir instead of process CWD --- drivers/windows/dir_access_windows.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 1d511c788b2..73df578cf82 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -329,7 +329,14 @@ Error DirAccessWindows::remove(String p_path) { uint64_t DirAccessWindows::get_space_left() { uint64_t bytes = 0; - if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) { + + String path = fix_path(current_dir); + + if (!path.ends_with("\\")) { + path += "\\"; + } + + if (!GetDiskFreeSpaceExW((LPCWSTR)(path.utf16().get_data()), (PULARGE_INTEGER)&bytes, nullptr, nullptr)) { return 0; }