update for HEAD-2003091401
[reactos.git] / lib / kernel32 / file / dir.c
index 8736996..a2a9a10 100644 (file)
@@ -23,6 +23,9 @@
 
 /* FUNCTIONS *****************************************************************/
 
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 CreateDirectoryA (
@@ -35,6 +38,10 @@ CreateDirectoryA (
                                   lpSecurityAttributes);
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 CreateDirectoryExA (
@@ -104,6 +111,9 @@ CreateDirectoryExA (
 }
 
 
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 CreateDirectoryW (
@@ -117,6 +127,9 @@ CreateDirectoryW (
 }
 
 
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 CreateDirectoryExW (
@@ -192,6 +205,9 @@ CreateDirectoryExW (
 }
 
 
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 RemoveDirectoryA (
@@ -225,6 +241,9 @@ RemoveDirectoryA (
 }
 
 
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 RemoveDirectoryW (
@@ -305,6 +324,9 @@ RemoveDirectoryW (
 }
 
 
+/*
+ * @implemented
+ */
 DWORD
 STDCALL
 GetFullPathNameA (
@@ -321,6 +343,7 @@ GetFullPathNameA (
        PWSTR FilePartU;
        ULONG BufferLength;
        ULONG Offset;
+       DWORD FullNameLen;
 
        DPRINT("GetFullPathNameA(lpFileName %s, nBufferLength %d, lpBuffer %p, "
               "lpFilePart %p)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart);
@@ -351,16 +374,21 @@ GetFullPathNameA (
        FullName.Length = 0;
        FullName.Buffer = lpBuffer;
 
-       RtlUnicodeStringToAnsiString (&FullName,
-                                     &FullNameU,
-                                     FALSE);
-
-       if (lpFilePart != NULL)
+        if (lpBuffer != NULL )
        {
-               Offset = (ULONG)(FilePartU - FullNameU.Buffer);
-               *lpFilePart = FullName.Buffer + Offset;
+               RtlUnicodeStringToAnsiString (&FullName,
+                                       &FullNameU,
+                                       FALSE);
+
+               if (lpFilePart != NULL)
+               {
+                       Offset = (ULONG)(FilePartU - FullNameU.Buffer);
+                       *lpFilePart = FullName.Buffer + Offset;
+               }
        }
 
+       FullNameLen = FullNameU.Length / sizeof(WCHAR);
+       
        RtlFreeHeap (RtlGetProcessHeap (),
                     0,
                     FullNameU.Buffer);
@@ -368,10 +396,13 @@ GetFullPathNameA (
        DPRINT("lpBuffer %s lpFilePart %s Length %ld\n",
               lpBuffer, lpFilePart, FullName.Length);
 
-       return FullName.Length;
+       return FullNameLen;
 }
 
 
+/*
+ * @implemented
+ */
 DWORD
 STDCALL
 GetFullPathNameW (
@@ -398,6 +429,9 @@ GetFullPathNameW (
 }
 
 
+/*
+ * @unimplemented
+ */
 DWORD
 STDCALL
 GetShortPathNameA (
@@ -421,6 +455,9 @@ GetShortPathNameA (
 }
 
 
+/*
+ * @unimplemented
+ */
 DWORD
 STDCALL
 GetShortPathNameW (
@@ -433,6 +470,9 @@ GetShortPathNameW (
 }
 
 
+/*
+ * @implemented
+ */
 DWORD
 STDCALL
 SearchPathA (
@@ -535,6 +575,9 @@ SearchPathA (
 }
 
 
+/*
+ * @implemented
+ */
 DWORD
 STDCALL
 SearchPathW (
@@ -598,6 +641,7 @@ SearchPathW (
                                                len * sizeof(WCHAR));
                if (EnvironmentBufferW == NULL)
                {
+                       SetLastError(ERROR_OUTOFMEMORY);
                        return 0;
                }
 
@@ -614,13 +658,18 @@ SearchPathW (
                lpPath = EnvironmentBufferW;
        }
 
-       retCode = RtlDosSearchPath_U ((PWCHAR)lpPath, (PWCHAR)lpFileName, (PWCHAR)lpExtension, nBufferLength, lpBuffer, lpFilePart);
+       retCode = RtlDosSearchPath_U ((PWCHAR)lpPath, (PWCHAR)lpFileName, (PWCHAR)lpExtension, 
+                                     nBufferLength * sizeof(WCHAR), lpBuffer, lpFilePart);
 
        if (EnvironmentBufferW != NULL)
        {
                RtlFreeHeap(GetProcessHeap(), 0, EnvironmentBufferW);
        }
-       return retCode;
+       if (retCode == 0)
+       {
+               SetLastError(ERROR_FILE_NOT_FOUND);
+       }
+       return retCode / sizeof(WCHAR);
 }
 
 /* EOF */