Commit in reactos/lib/kernel32/file on MAIN
create.c+20-61.41 -> 1.42
set correct last error

reactos/lib/kernel32/file
create.c 1.41 -> 1.42
diff -u -r1.41 -r1.42
--- create.c	29 Nov 2004 17:31:21 -0000	1.41
+++ create.c	6 Dec 2004 14:24:51 -0000	1.42
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.41 2004/11/29 17:31:21 gdalsnes Exp $
+/* $Id: create.c,v 1.42 2004/12/06 14:24:51 gdalsnes Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -271,11 +271,25 @@
    RtlFreeUnicodeString(&NtPathU);
 
    /* error */
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastErrorByStatus (Status);
-    return INVALID_HANDLE_VALUE;
-  }
+   if (!NT_SUCCESS(Status))
+   {
+      /* In the case file creation was rejected due to CREATE_NEW flag
+       * was specified and file with that name already exists, correct
+       * last error is ERROR_FILE_EXISTS and not ERROR_ALREADY_EXISTS.
+       * Note: RtlNtStatusToDosError is not the subject to blame here.
+       */
+      if (Status == STATUS_OBJECT_NAME_COLLISION &&
+          dwCreationDisposition == FILE_CREATE)
+      {
+         SetLastError( ERROR_FILE_EXISTS );
+      }
+      else
+      {
+         SetLastErrorByStatus (Status);
+      }
+     
+      return INVALID_HANDLE_VALUE;
+   }
    
   /*
   create with OPEN_ALWAYS (FILE_OPEN_IF) returns info = FILE_OPENED or FILE_CREATED
CVSspam 0.2.8