浏览代码

Merge pull request #108964 from moluopro/master

Fix: Make `get_space_left` on Windows use `current_dir` instead of process CWD
Thaddeus Crews 1 月之前
父节点
当前提交
c0a2eee7ae
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      drivers/windows/dir_access_windows.cpp

+ 8 - 1
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;
 	}