Skip to content

Commit c0a2eee

Browse files
committed
Merge pull request #108964 from moluopro/master
Fix: Make `get_space_left` on Windows use `current_dir` instead of process CWD
2 parents 11dcbd4 + 39fba21 commit c0a2eee

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)