[KERNEL32]: Reimplement GetDiskFreeSpaceExA() to make it w2k3 compliant
[reactos.git] / 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);
 }
 
 /*