- Fix Get[System/Window]Directory[AW] for Buffer == NULL case.
authorFilip Navara <filip.navara@gmail.com>
Tue, 24 Aug 2004 17:15:42 +0000 (17:15 +0000)
committerFilip Navara <filip.navara@gmail.com>
Tue, 24 Aug 2004 17:15:42 +0000 (17:15 +0000)
- Fix return value of GetDriveType[AW].

svn path=/trunk/; revision=10667

reactos/lib/kernel32/file/curdir.c
reactos/lib/kernel32/file/volume.c

index 56405ad..aebfd7d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: curdir.c,v 1.43 2004/06/06 17:29:57 hbirr Exp $
+/* $Id: curdir.c,v 1.44 2004/08/24 17:15:42 navaraf Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -270,11 +270,11 @@ GetSystemDirectoryA (
        ULONG Length;
        NTSTATUS Status;
 
-       if (lpBuffer == NULL)
-               return 0;
-
        Length = RtlUnicodeStringToAnsiSize (&SystemDirectory);   //len of ansi str incl. nullchar
 
+       if (lpBuffer == NULL)
+               return Length;
+
        if (uSize >= Length){
                String.Length = 0;
                String.MaximumLength = uSize;
@@ -312,10 +312,11 @@ GetSystemDirectoryW (
 {
        ULONG Length;
 
+       Length = SystemDirectory.Length / sizeof (WCHAR);
+
        if (lpBuffer == NULL)
-               return 0;
+               return Length + 1;
 
-       Length = SystemDirectory.Length / sizeof (WCHAR);
        if (uSize > Length)     {
                memmove (lpBuffer,
                         SystemDirectory.Buffer,
@@ -342,11 +343,11 @@ GetWindowsDirectoryA (
        ULONG Length;
        NTSTATUS Status;
 
-       if (lpBuffer == NULL)
-               return 0;
-
        Length = RtlUnicodeStringToAnsiSize (&WindowsDirectory); //len of ansi str incl. nullchar
        
+       if (lpBuffer == NULL)
+               return Length;
+
        if (uSize >= Length){
 
                String.Length = 0;
@@ -385,10 +386,11 @@ GetWindowsDirectoryW (
 {
        ULONG Length;
 
+       Length = WindowsDirectory.Length / sizeof (WCHAR);
+
        if (lpBuffer == NULL)
-               return 0;
+               return Length + 1;
 
-       Length = WindowsDirectory.Length / sizeof (WCHAR);
        if (uSize > Length)
        {
                memmove (lpBuffer,
index 0b3e26a..cc35134 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: volume.c,v 1.40 2004/02/25 09:55:30 gvg Exp $
+/* $Id: volume.c,v 1.41 2004/08/24 17:15:42 navaraf Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -448,7 +448,25 @@ GetDriveTypeW(LPCWSTR lpRootPathName)
                return 0;       
        }
        CloseHandle(hFile);
-       return (UINT)FileFsDevice.DeviceType;
+
+        switch (FileFsDevice.DeviceType)
+        {
+               case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
+                       return DRIVE_CDROM;
+               case FILE_DEVICE_VIRTUAL_DISK:
+                       return DRIVE_RAMDISK;
+               case FILE_DEVICE_NETWORK_FILE_SYSTEM:
+                       return DRIVE_REMOTE;
+               case FILE_DEVICE_DISK:
+               case FILE_DEVICE_DISK_FILE_SYSTEM:
+                       if (FileFsDevice.Characteristics & FILE_REMOTE_DEVICE)
+                               return DRIVE_REMOTE;
+                       if (FileFsDevice.Characteristics & FILE_REMOVABLE_MEDIA)
+                               return DRIVE_REMOVABLE;
+                       return DRIVE_FIXED;
+        }
+
+       return DRIVE_UNKNOWN;
 }