2 * File handling functions
4 * Copyright 1993 John Burton
5 * Copyright 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Fix the CopyFileEx methods to implement the "extended" functionality.
23 * Right now, they simply call the CopyFile method.
27 #include "wine/port.h"
37 #ifdef HAVE_SYS_ERRNO_H
38 #include <sys/errno.h>
40 #include <sys/types.h>
42 #ifdef HAVE_SYS_MMAN_H
45 #ifdef HAVE_SYS_TIME_H
46 # include <sys/time.h>
48 #ifdef HAVE_SYS_POLL_H
49 # include <sys/poll.h>
62 #define NONAMELESSUNION
63 #define NONAMELESSSTRUCT
70 #include "wine/winbase16.h"
71 #include "wine/server.h"
75 #include "kernel_private.h"
78 #include "wine/unicode.h"
79 #include "wine/debug.h"
81 WINE_DEFAULT_DEBUG_CHANNEL(file);
84 /***********************************************************************
87 * Convert OF_* mode into flags for CreateFile.
89 void FILE_ConvertOFMode( INT mode, DWORD *access, DWORD *sharing )
93 case OF_READ: *access = GENERIC_READ; break;
94 case OF_WRITE: *access = GENERIC_WRITE; break;
95 case OF_READWRITE: *access = GENERIC_READ | GENERIC_WRITE; break;
96 default: *access = 0; break;
100 case OF_SHARE_EXCLUSIVE: *sharing = 0; break;
101 case OF_SHARE_DENY_WRITE: *sharing = FILE_SHARE_READ; break;
102 case OF_SHARE_DENY_READ: *sharing = FILE_SHARE_WRITE; break;
103 case OF_SHARE_DENY_NONE:
104 case OF_SHARE_COMPAT:
105 default: *sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break;
110 /***********************************************************************
113 * Set the DOS error code from errno.
115 void FILE_SetDosError(void)
117 int save_errno = errno; /* errno gets overwritten by printf */
119 TRACE("errno = %d %s\n", errno, strerror(errno));
123 SetLastError( ERROR_SHARING_VIOLATION );
126 SetLastError( ERROR_INVALID_HANDLE );
129 SetLastError( ERROR_HANDLE_DISK_FULL );
134 SetLastError( ERROR_ACCESS_DENIED );
137 SetLastError( ERROR_LOCK_VIOLATION );
140 SetLastError( ERROR_FILE_NOT_FOUND );
143 SetLastError( ERROR_CANNOT_MAKE );
147 SetLastError( ERROR_TOO_MANY_OPEN_FILES );
150 SetLastError( ERROR_FILE_EXISTS );
154 SetLastError( ERROR_SEEK );
157 SetLastError( ERROR_DIR_NOT_EMPTY );
160 SetLastError( ERROR_BAD_FORMAT );
163 SetLastError( ERROR_PATH_NOT_FOUND );
166 SetLastError( ERROR_NOT_SAME_DEVICE );
169 WARN("unknown file error: %s\n", strerror(save_errno) );
170 SetLastError( ERROR_GEN_FAILURE );
177 /*************************************************************************
178 * CreateFileW [KERNEL32.@] Creates or opens a file or other object
180 * Creates or opens an object, and returns a handle that can be used to
181 * access that object.
185 * filename [in] pointer to filename to be accessed
186 * access [in] access mode requested
187 * sharing [in] share mode
188 * sa [in] pointer to security attributes
189 * creation [in] how to create the file
190 * attributes [in] attributes for newly created file
191 * template [in] handle to file with extended attributes to copy
194 * Success: Open handle to specified file
195 * Failure: INVALID_HANDLE_VALUE
198 * Should call SetLastError() on failure.
202 * Doesn't support character devices, template files, or a
203 * lot of the 'attributes' flags yet.
205 HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
206 LPSECURITY_ATTRIBUTES sa, DWORD creation,
207 DWORD attributes, HANDLE template )
211 OBJECT_ATTRIBUTES attr;
212 UNICODE_STRING nameW;
216 static const WCHAR bkslashes_with_dotW[] = {'\\','\\','.','\\',0};
217 static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
218 static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
220 static const char * const creation_name[5] =
221 { "CREATE_NEW", "CREATE_ALWAYS", "OPEN_EXISTING", "OPEN_ALWAYS", "TRUNCATE_EXISTING" };
223 static const UINT nt_disposition[5] =
225 FILE_CREATE, /* CREATE_NEW */
226 FILE_OVERWRITE_IF, /* CREATE_ALWAYS */
227 FILE_OPEN, /* OPEN_EXISTING */
228 FILE_OPEN_IF, /* OPEN_ALWAYS */
229 FILE_OVERWRITE /* TRUNCATE_EXISTING */
235 if (!filename || !filename[0])
237 SetLastError( ERROR_PATH_NOT_FOUND );
238 return INVALID_HANDLE_VALUE;
241 if (creation < CREATE_NEW || creation > TRUNCATE_EXISTING)
243 SetLastError( ERROR_INVALID_PARAMETER );
244 return INVALID_HANDLE_VALUE;
247 TRACE("%s %s%s%s%s%s%s%s attributes 0x%lx\n", debugstr_w(filename),
248 (access & GENERIC_READ)?"GENERIC_READ ":"",
249 (access & GENERIC_WRITE)?"GENERIC_WRITE ":"",
250 (!access)?"QUERY_ACCESS ":"",
251 (sharing & FILE_SHARE_READ)?"FILE_SHARE_READ ":"",
252 (sharing & FILE_SHARE_WRITE)?"FILE_SHARE_WRITE ":"",
253 (sharing & FILE_SHARE_DELETE)?"FILE_SHARE_DELETE ":"",
254 creation_name[creation - CREATE_NEW], attributes);
256 /* Open a console for CONIN$ or CONOUT$ */
258 if (!strcmpiW(filename, coninW) || !strcmpiW(filename, conoutW))
260 ret = OpenConsoleW(filename, access, (sa && sa->bInheritHandle), creation);
264 if (!strncmpW(filename, bkslashes_with_dotW, 4))
266 static const WCHAR pipeW[] = {'P','I','P','E','\\',0};
268 if ((isalphaW(filename[4]) && filename[5] == ':' && filename[6] == '\0') ||
269 !strncmpiW( filename + 4, pipeW, 5 ))
273 else if ((dosdev = RtlIsDosDeviceName_U( filename + 4 )))
275 dosdev += MAKELONG( 0, 4*sizeof(WCHAR) ); /* adjust position to start of filename */
277 else if (filename[4])
279 ret = VXD_Open( filename+4, access, sa );
284 SetLastError( ERROR_INVALID_NAME );
285 return INVALID_HANDLE_VALUE;
288 else dosdev = RtlIsDosDeviceName_U( filename );
292 static const WCHAR conW[] = {'C','O','N'};
294 if (LOWORD(dosdev) == sizeof(conW) &&
295 !memicmpW( filename + HIWORD(dosdev)/sizeof(WCHAR), conW, sizeof(conW)))
297 switch (access & (GENERIC_READ|GENERIC_WRITE))
300 ret = OpenConsoleW(coninW, access, (sa && sa->bInheritHandle), creation);
303 ret = OpenConsoleW(conoutW, access, (sa && sa->bInheritHandle), creation);
306 SetLastError( ERROR_FILE_NOT_FOUND );
307 return INVALID_HANDLE_VALUE;
312 if (!RtlDosPathNameToNtPathName_U( filename, &nameW, NULL, NULL ))
314 SetLastError( ERROR_PATH_NOT_FOUND );
315 return INVALID_HANDLE_VALUE;
318 /* now call NtCreateFile */
321 if (attributes & FILE_FLAG_BACKUP_SEMANTICS)
322 options |= FILE_OPEN_FOR_BACKUP_INTENT;
324 options |= FILE_NON_DIRECTORY_FILE;
325 if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
326 options |= FILE_DELETE_ON_CLOSE;
327 if (!(attributes & FILE_FLAG_OVERLAPPED))
328 options |= FILE_SYNCHRONOUS_IO_ALERT;
329 if (attributes & FILE_FLAG_RANDOM_ACCESS)
330 options |= FILE_RANDOM_ACCESS;
331 attributes &= FILE_ATTRIBUTE_VALID_FLAGS;
333 attr.Length = sizeof(attr);
334 attr.RootDirectory = 0;
335 attr.Attributes = OBJ_CASE_INSENSITIVE;
336 attr.ObjectName = &nameW;
337 attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
338 attr.SecurityQualityOfService = NULL;
340 if (sa && sa->bInheritHandle) attr.Attributes |= OBJ_INHERIT;
342 status = NtCreateFile( &ret, access, &attr, &io, NULL, attributes,
343 sharing, nt_disposition[creation - CREATE_NEW],
347 WARN("Unable to create file %s (status %lx)\n", debugstr_w(filename), status);
348 ret = INVALID_HANDLE_VALUE;
350 /* In the case file creation was rejected due to CREATE_NEW flag
351 * was specified and file with that name already exists, correct
352 * last error is ERROR_FILE_EXISTS and not ERROR_ALREADY_EXISTS.
353 * Note: RtlNtStatusToDosError is not the subject to blame here.
355 if (status == STATUS_OBJECT_NAME_COLLISION)
356 SetLastError( ERROR_FILE_EXISTS );
358 SetLastError( RtlNtStatusToDosError(status) );
360 else SetLastError(0);
361 RtlFreeUnicodeString( &nameW );
364 if (!ret) ret = INVALID_HANDLE_VALUE;
365 TRACE("returning %p\n", ret);
371 /*************************************************************************
372 * CreateFileA (KERNEL32.@)
374 HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
375 LPSECURITY_ATTRIBUTES sa, DWORD creation,
376 DWORD attributes, HANDLE template)
378 UNICODE_STRING filenameW;
379 HANDLE ret = INVALID_HANDLE_VALUE;
383 SetLastError( ERROR_INVALID_PARAMETER );
384 return INVALID_HANDLE_VALUE;
387 if (RtlCreateUnicodeStringFromAsciiz(&filenameW, filename))
389 ret = CreateFileW(filenameW.Buffer, access, sharing, sa, creation,
390 attributes, template);
391 RtlFreeUnicodeString(&filenameW);
394 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
399 /***********************************************************************
400 * GetTempFileNameA (KERNEL32.@)
402 UINT WINAPI GetTempFileNameA( LPCSTR path, LPCSTR prefix, UINT unique,
405 UNICODE_STRING pathW, prefixW;
406 WCHAR bufferW[MAX_PATH];
409 if ( !path || !prefix || !buffer )
411 SetLastError( ERROR_INVALID_PARAMETER );
415 RtlCreateUnicodeStringFromAsciiz(&pathW, path);
416 RtlCreateUnicodeStringFromAsciiz(&prefixW, prefix);
418 ret = GetTempFileNameW(pathW.Buffer, prefixW.Buffer, unique, bufferW);
420 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_PATH, NULL, NULL);
422 RtlFreeUnicodeString(&pathW);
423 RtlFreeUnicodeString(&prefixW);
427 /***********************************************************************
428 * GetTempFileNameW (KERNEL32.@)
430 UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique,
433 static const WCHAR formatW[] = {'%','x','.','t','m','p',0};
438 if ( !path || !prefix || !buffer )
440 SetLastError( ERROR_INVALID_PARAMETER );
444 strcpyW( buffer, path );
445 p = buffer + strlenW(buffer);
447 /* add a \, if there isn't one */
448 if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\';
450 for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++;
454 if (unique) sprintfW( p, formatW, unique );
457 /* get a "random" unique number and try to create the file */
459 UINT num = GetTickCount() & 0xffff;
465 sprintfW( p, formatW, unique );
466 handle = CreateFileW( buffer, GENERIC_WRITE, 0, NULL,
467 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
468 if (handle != INVALID_HANDLE_VALUE)
469 { /* We created it */
470 TRACE("created %s\n", debugstr_w(buffer) );
471 CloseHandle( handle );
474 if (GetLastError() != ERROR_FILE_EXISTS &&
475 GetLastError() != ERROR_SHARING_VIOLATION)
476 break; /* No need to go on */
477 if (!(++unique & 0xffff)) unique = 1;
478 } while (unique != num);
481 TRACE("returning %s\n", debugstr_w(buffer) );
486 /******************************************************************
487 * FILE_ReadWriteApc (internal)
491 static void WINAPI FILE_ReadWriteApc(void* apc_user, PIO_STATUS_BLOCK io_status, ULONG len)
493 LPOVERLAPPED_COMPLETION_ROUTINE cr = (LPOVERLAPPED_COMPLETION_ROUTINE)apc_user;
495 cr(RtlNtStatusToDosError(io_status->u.Status), len, (LPOVERLAPPED)io_status);
498 /***********************************************************************
499 * ReadFileEx (KERNEL32.@)
501 BOOL WINAPI ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
502 LPOVERLAPPED overlapped,
503 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
505 LARGE_INTEGER offset;
507 PIO_STATUS_BLOCK io_status;
511 SetLastError(ERROR_INVALID_PARAMETER);
515 offset.u.LowPart = overlapped->Offset;
516 offset.u.HighPart = overlapped->OffsetHigh;
517 io_status = (PIO_STATUS_BLOCK)overlapped;
518 io_status->u.Status = STATUS_PENDING;
520 status = NtReadFile(hFile, NULL, FILE_ReadWriteApc, lpCompletionRoutine,
521 io_status, buffer, bytesToRead, &offset, NULL);
525 SetLastError( RtlNtStatusToDosError(status) );
531 /***********************************************************************
532 * ReadFile (KERNEL32.@)
534 BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
535 LPDWORD bytesRead, LPOVERLAPPED overlapped )
537 LARGE_INTEGER offset;
538 PLARGE_INTEGER poffset = NULL;
539 IO_STATUS_BLOCK iosb;
540 PIO_STATUS_BLOCK io_status = &iosb;
544 TRACE("%p %p %ld %p %p\n", hFile, buffer, bytesToRead,
545 bytesRead, overlapped );
547 if (bytesRead) *bytesRead = 0; /* Do this before anything else */
548 if (!bytesToRead) return TRUE;
550 if (IsBadReadPtr(buffer, bytesToRead))
552 SetLastError(ERROR_WRITE_FAULT); /* FIXME */
555 if (is_console_handle(hFile))
556 return ReadConsoleA(hFile, buffer, bytesToRead, bytesRead, NULL);
558 if (overlapped != NULL)
560 offset.u.LowPart = overlapped->Offset;
561 offset.u.HighPart = overlapped->OffsetHigh;
563 hEvent = overlapped->hEvent;
564 io_status = (PIO_STATUS_BLOCK)overlapped;
566 io_status->u.Status = STATUS_PENDING;
567 io_status->Information = 0;
569 status = NtReadFile(hFile, hEvent, NULL, NULL, io_status, buffer, bytesToRead, poffset, NULL);
571 if (status != STATUS_PENDING && bytesRead)
572 *bytesRead = io_status->Information;
574 if (status && status != STATUS_END_OF_FILE)
576 SetLastError( RtlNtStatusToDosError(status) );
583 /***********************************************************************
584 * WriteFileEx (KERNEL32.@)
586 BOOL WINAPI WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
587 LPOVERLAPPED overlapped,
588 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
590 LARGE_INTEGER offset;
592 PIO_STATUS_BLOCK io_status;
594 TRACE("%p %p %ld %p %p\n",
595 hFile, buffer, bytesToWrite, overlapped, lpCompletionRoutine);
597 if (overlapped == NULL)
599 SetLastError(ERROR_INVALID_PARAMETER);
602 offset.u.LowPart = overlapped->Offset;
603 offset.u.HighPart = overlapped->OffsetHigh;
605 io_status = (PIO_STATUS_BLOCK)overlapped;
606 io_status->u.Status = STATUS_PENDING;
608 status = NtWriteFile(hFile, NULL, FILE_ReadWriteApc, lpCompletionRoutine,
609 io_status, buffer, bytesToWrite, &offset, NULL);
611 if (status) SetLastError( RtlNtStatusToDosError(status) );
615 /***********************************************************************
616 * WriteFile (KERNEL32.@)
618 BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
619 LPDWORD bytesWritten, LPOVERLAPPED overlapped )
621 HANDLE hEvent = NULL;
622 LARGE_INTEGER offset;
623 PLARGE_INTEGER poffset = NULL;
625 IO_STATUS_BLOCK iosb;
626 PIO_STATUS_BLOCK piosb = &iosb;
628 TRACE("%p %p %ld %p %p\n",
629 hFile, buffer, bytesToWrite, bytesWritten, overlapped );
631 if (is_console_handle(hFile))
632 return WriteConsoleA(hFile, buffer, bytesToWrite, bytesWritten, NULL);
634 if (IsBadReadPtr(buffer, bytesToWrite))
636 SetLastError(ERROR_READ_FAULT); /* FIXME */
642 offset.u.LowPart = overlapped->Offset;
643 offset.u.HighPart = overlapped->OffsetHigh;
645 hEvent = overlapped->hEvent;
646 piosb = (PIO_STATUS_BLOCK)overlapped;
648 piosb->u.Status = STATUS_PENDING;
649 piosb->Information = 0;
651 status = NtWriteFile(hFile, hEvent, NULL, NULL, piosb,
652 buffer, bytesToWrite, poffset, NULL);
655 SetLastError( RtlNtStatusToDosError(status) );
658 if (bytesWritten) *bytesWritten = piosb->Information;
664 /***********************************************************************
665 * SetFilePointer (KERNEL32.@)
667 DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
670 static const int whence[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
671 DWORD ret = INVALID_SET_FILE_POINTER;
675 TRACE("handle %p offset %ld high %ld origin %ld\n",
676 hFile, distance, highword?*highword:0, method );
678 if (method > FILE_END)
680 SetLastError( ERROR_INVALID_PARAMETER );
684 if (!(status = wine_server_handle_to_fd( hFile, 0, &fd, NULL, NULL )))
688 if (highword) pos = ((off_t)*highword << 32) | (ULONG)distance;
689 else pos = (off_t)distance;
690 if ((res = lseek( fd, pos, whence[method] )) == (off_t)-1)
692 /* also check EPERM due to SuSE7 2.2.16 lseek() EPERM kernel bug */
693 if (((errno == EINVAL) || (errno == EPERM)) && (method != FILE_BEGIN) && (pos < 0))
694 SetLastError( ERROR_NEGATIVE_SEEK );
701 if (highword) *highword = (res >> 32);
702 if (ret == INVALID_SET_FILE_POINTER) SetLastError( 0 );
704 wine_server_release_fd( hFile, fd );
706 else SetLastError( RtlNtStatusToDosError(status) );
712 /*************************************************************************
713 * SetHandleCount (KERNEL32.@)
715 UINT WINAPI SetHandleCount( UINT count )
717 return min( 256, count );
721 /**************************************************************************
722 * SetEndOfFile (KERNEL32.@)
724 BOOL WINAPI SetEndOfFile( HANDLE hFile )
727 SERVER_START_REQ( truncate_file )
730 ret = !wine_server_call_err( req );
737 /***********************************************************************
738 * GetFileType (KERNEL32.@)
740 DWORD WINAPI GetFileType( HANDLE hFile )
744 DWORD ret = FILE_TYPE_UNKNOWN;
746 if (is_console_handle( hFile ))
747 return FILE_TYPE_CHAR;
749 if (!(status = wine_server_handle_to_fd( hFile, 0, &fd, NULL, NULL )))
753 if (fstat( fd, &st ) == -1)
755 else if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
756 ret = FILE_TYPE_PIPE;
757 else if (S_ISCHR(st.st_mode))
758 ret = FILE_TYPE_CHAR;
760 ret = FILE_TYPE_DISK;
761 wine_server_release_fd( hFile, fd );
763 else SetLastError( RtlNtStatusToDosError(status) );
769 /**************************************************************************
770 * CopyFileW (KERNEL32.@)
772 BOOL WINAPI CopyFileW( LPCWSTR source, LPCWSTR dest, BOOL fail_if_exists )
775 BY_HANDLE_FILE_INFORMATION info;
780 if (!source || !dest)
782 SetLastError(ERROR_INVALID_PARAMETER);
786 TRACE("%s -> %s\n", debugstr_w(source), debugstr_w(dest));
788 if ((h1 = CreateFileW(source, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
789 NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
791 WARN("Unable to open source %s\n", debugstr_w(source));
795 if (!GetFileInformationByHandle( h1, &info ))
797 WARN("GetFileInformationByHandle returned error for %s\n", debugstr_w(source));
802 if ((h2 = CreateFileW( dest, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
803 fail_if_exists ? CREATE_NEW : CREATE_ALWAYS,
804 info.dwFileAttributes, h1 )) == INVALID_HANDLE_VALUE)
806 WARN("Unable to open dest %s\n", debugstr_w(dest));
811 while (ReadFile( h1, buffer, sizeof(buffer), &count, NULL ) && count)
817 if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
830 /**************************************************************************
831 * CopyFileA (KERNEL32.@)
833 BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists)
835 UNICODE_STRING sourceW, destW;
838 if (!source || !dest)
840 SetLastError(ERROR_INVALID_PARAMETER);
844 RtlCreateUnicodeStringFromAsciiz(&sourceW, source);
845 RtlCreateUnicodeStringFromAsciiz(&destW, dest);
847 ret = CopyFileW(sourceW.Buffer, destW.Buffer, fail_if_exists);
849 RtlFreeUnicodeString(&sourceW);
850 RtlFreeUnicodeString(&destW);
855 /**************************************************************************
856 * CopyFileExW (KERNEL32.@)
858 * This implementation ignores most of the extra parameters passed-in into
859 * the "ex" version of the method and calls the CopyFile method.
860 * It will have to be fixed eventually.
862 BOOL WINAPI CopyFileExW(LPCWSTR sourceFilename, LPCWSTR destFilename,
863 LPPROGRESS_ROUTINE progressRoutine, LPVOID appData,
864 LPBOOL cancelFlagPointer, DWORD copyFlags)
867 * Interpret the only flag that CopyFile can interpret.
869 return CopyFileW(sourceFilename, destFilename, (copyFlags & COPY_FILE_FAIL_IF_EXISTS) != 0);
873 /**************************************************************************
874 * CopyFileExA (KERNEL32.@)
876 BOOL WINAPI CopyFileExA(LPCSTR sourceFilename, LPCSTR destFilename,
877 LPPROGRESS_ROUTINE progressRoutine, LPVOID appData,
878 LPBOOL cancelFlagPointer, DWORD copyFlags)
880 UNICODE_STRING sourceW, destW;
883 if (!sourceFilename || !destFilename)
885 SetLastError(ERROR_INVALID_PARAMETER);
889 RtlCreateUnicodeStringFromAsciiz(&sourceW, sourceFilename);
890 RtlCreateUnicodeStringFromAsciiz(&destW, destFilename);
892 ret = CopyFileExW(sourceW.Buffer, destW.Buffer, progressRoutine, appData,
893 cancelFlagPointer, copyFlags);
895 RtlFreeUnicodeString(&sourceW);
896 RtlFreeUnicodeString(&destW);