[KERNEL32]: Reimplement GetDiskFreeSpaceExA() to make it w2k3 compliant
authorPierre Schweitzer <pierre@reactos.org>
Wed, 4 Oct 2017 21:02:22 +0000 (23:02 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 5 Oct 2017 20:14:44 +0000 (22:14 +0200)
dll/win32/kernel32/client/file/disk.c

index 1ba1b73..1b7d1e3 100644 (file)
@@ -359,18 +359,23 @@ GetDiskFreeSpaceExA(IN LPCSTR lpDirectoryName OPTIONAL,
                     OUT PULARGE_INTEGER lpTotalNumberOfBytes,
                     OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
 {
-    PWCHAR DirectoryNameW=NULL;
+    PCSTR RootPath;
+    PUNICODE_STRING RootPathU;
 
-    if (lpDirectoryName)
+    RootPath = lpDirectoryName;
+    if (RootPath == NULL)
     {
-        if (!(DirectoryNameW = FilenameA2W(lpDirectoryName, FALSE)))
-            return FALSE;
+        RootPath = "\\";
+    }
+
+    RootPathU = Basep8BitStringToStaticUnicodeString(RootPath);
+    if (RootPathU == NULL)
+    {
+        return FALSE;
     }
 
-    return GetDiskFreeSpaceExW (DirectoryNameW ,
-                                lpFreeBytesAvailableToCaller,
-                                lpTotalNumberOfBytes,
-                                lpTotalNumberOfFreeBytes);
+    return GetDiskFreeSpaceExW(RootPathU->Buffer, lpFreeBytesAvailableToCaller,
+                              lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes);
 }
 
 /*