[KERNEL32]
[reactos.git] / reactos / dll / win32 / kernel32 / client / file / copy.c
index 47b8199..99b96c1 100644 (file)
@@ -149,7 +149,7 @@ CopyLoop (
     }
     else
     {
-        TRACE("Error 0x%08x allocating buffer of %d bytes\n", errCode, RegionSize);
+        TRACE("Error 0x%08x allocating buffer of %lu bytes\n", errCode, RegionSize);
     }
 
     return errCode;
@@ -293,7 +293,7 @@ CopyFileExW (
                 }
                 else
                 {
-                    WARN("Error %d during opening of dest file\n", GetLastError());
+                    WARN("Error %lu during opening of dest file\n", GetLastError());
                 }
             }
         }
@@ -301,7 +301,7 @@ CopyFileExW (
     }
     else
     {
-        WARN("Error %d during opening of source file\n", GetLastError());
+        WARN("Error %lu during opening of source file\n", GetLastError());
     }
 
     return RC;
@@ -325,7 +325,7 @@ CopyFileExA(IN LPCSTR lpExistingFileName,
     PUNICODE_STRING lpExistingFileNameW;
 
     lpExistingFileNameW = Basep8BitStringToStaticUnicodeString(lpExistingFileName);
-    if (!lpExistingFileName)
+    if (!lpExistingFileNameW)
     {
         return FALSE;
     }
@@ -351,18 +351,33 @@ CopyFileExA(IN LPCSTR lpExistingFileName,
  */
 BOOL
 WINAPI
-CopyFileA (
-    LPCSTR     lpExistingFileName,
-    LPCSTR     lpNewFileName,
-    BOOL       bFailIfExists
-)
+CopyFileA(IN LPCSTR lpExistingFileName,
+          IN LPCSTR lpNewFileName,
+          IN BOOL bFailIfExists)
 {
-    return CopyFileExA (lpExistingFileName,
-                        lpNewFileName,
-                        NULL,
-                        NULL,
-                        NULL,
-                        bFailIfExists);
+    BOOL Result = FALSE;
+    UNICODE_STRING lpNewFileNameW;
+    PUNICODE_STRING lpExistingFileNameW;
+
+    lpExistingFileNameW = Basep8BitStringToStaticUnicodeString(lpExistingFileName);
+    if (!lpExistingFileNameW)
+    {
+        return FALSE;
+    }
+
+    if (Basep8BitStringToDynamicUnicodeString(&lpNewFileNameW, lpNewFileName))
+    {
+        Result = CopyFileExW(lpExistingFileNameW->Buffer,
+                             lpNewFileNameW.Buffer,
+                             NULL,
+                             NULL,
+                             NULL,
+                             (bFailIfExists ? COPY_FILE_FAIL_IF_EXISTS : 0));
+
+        RtlFreeUnicodeString(&lpNewFileNameW);
+    }
+
+    return Result;
 }
 
 
@@ -371,18 +386,16 @@ CopyFileA (
  */
 BOOL
 WINAPI
-CopyFileW (
-    LPCWSTR    lpExistingFileName,
-    LPCWSTR    lpNewFileName,
-    BOOL       bFailIfExists
-)
+CopyFileW(IN LPCWSTR lpExistingFileName,
+          IN LPCWSTR lpNewFileName,
+          IN BOOL bFailIfExists)
 {
-    return CopyFileExW (lpExistingFileName,
-                        lpNewFileName,
-                        NULL,
-                        NULL,
-                        NULL,
-                        bFailIfExists);
+    return CopyFileExW(lpExistingFileName,
+                       lpNewFileName,
+                       NULL,
+                       NULL,
+                       NULL,
+                       (bFailIfExists ? COPY_FILE_FAIL_IF_EXISTS : 0));
 }