GetBinaryTypeA, CopyFileExA, CreateFileA, DeleteFileA, MoveFileWithProgressA: Use common A2W conv. routines

svn path=/trunk/; revision=14227
This commit is contained in:
Gunnar Dalsnes 2005-03-20 17:39:11 +00:00
parent de75c774c3
commit 124f38a790
5 changed files with 35 additions and 135 deletions

View file

@ -304,10 +304,7 @@ GetBinaryTypeA (
LPDWORD lpBinaryType LPDWORD lpBinaryType
) )
{ {
ANSI_STRING FileNameA; PWCHAR ApplicationNameW;
UNICODE_STRING FileName;
NTSTATUS Status;
BOOL Ret;
if(!lpApplicationName || !lpBinaryType) if(!lpApplicationName || !lpBinaryType)
{ {
@ -315,22 +312,10 @@ GetBinaryTypeA (
return FALSE; return FALSE;
} }
RtlInitAnsiString(&FileNameA, (LPSTR)lpApplicationName); if (!(ApplicationNameW = FilenameA2W(lpApplicationName, FALSE)))
return FALSE;
if(bIsFileApiAnsi) return GetBinaryTypeW(ApplicationNameW, lpBinaryType);
Status = RtlAnsiStringToUnicodeString(&FileName, &FileNameA, TRUE);
else
Status = RtlOemStringToUnicodeString(&FileName, &FileNameA, TRUE);
if(!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
Ret = GetBinaryTypeW(FileName.Buffer, lpBinaryType);
RtlFreeUnicodeString(&FileName);
return Ret;
} }
/* EOF */ /* EOF */

View file

@ -321,40 +321,18 @@ CopyFileExA (
DWORD dwCopyFlags DWORD dwCopyFlags
) )
{ {
UNICODE_STRING ExistingFileNameU; PWCHAR ExistingFileNameW;
UNICODE_STRING NewFileNameU; PWCHAR NewFileNameW;
ANSI_STRING ExistingFileName;
ANSI_STRING NewFileName;
BOOL Result; BOOL Result;
RtlInitAnsiString (&ExistingFileName, if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
(LPSTR)lpExistingFileName); return FALSE;
RtlInitAnsiString (&NewFileName, if (!(NewFileNameW = FilenameA2W(lpNewFileName, TRUE)))
(LPSTR)lpNewFileName); return FALSE;
/* convert ansi (or oem) string to unicode */ Result = CopyFileExW (ExistingFileNameW ,
if (bIsFileApiAnsi) NewFileNameW ,
{
RtlAnsiStringToUnicodeString (&ExistingFileNameU,
&ExistingFileName,
TRUE);
RtlAnsiStringToUnicodeString (&NewFileNameU,
&NewFileName,
TRUE);
}
else
{
RtlOemStringToUnicodeString (&ExistingFileNameU,
&ExistingFileName,
TRUE);
RtlOemStringToUnicodeString (&NewFileNameU,
&NewFileName,
TRUE);
}
Result = CopyFileExW (ExistingFileNameU.Buffer,
NewFileNameU.Buffer,
lpProgressRoutine, lpProgressRoutine,
lpData, lpData,
pbCancel, pbCancel,
@ -362,10 +340,7 @@ CopyFileExA (
RtlFreeHeap (RtlGetProcessHeap (), RtlFreeHeap (RtlGetProcessHeap (),
0, 0,
ExistingFileNameU.Buffer); NewFileNameW);
RtlFreeHeap (RtlGetProcessHeap (),
0,
NewFileNameU.Buffer);
return Result; return Result;
} }

View file

@ -34,26 +34,15 @@ HANDLE STDCALL CreateFileA (LPCSTR lpFileName,
DWORD dwFlagsAndAttributes, DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile) HANDLE hTemplateFile)
{ {
UNICODE_STRING FileNameU; PWCHAR FileNameW;
ANSI_STRING FileName;
HANDLE FileHandle; HANDLE FileHandle;
DPRINT("CreateFileA(lpFileName %s)\n",lpFileName); DPRINT("CreateFileA(lpFileName %s)\n",lpFileName);
RtlInitAnsiString (&FileName,
(LPSTR)lpFileName);
/* convert ansi (or oem) string to unicode */
if (bIsFileApiAnsi)
RtlAnsiStringToUnicodeString (&FileNameU,
&FileName,
TRUE);
else
RtlOemStringToUnicodeString (&FileNameU,
&FileName,
TRUE);
FileHandle = CreateFileW (FileNameU.Buffer, if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
return INVALID_HANDLE_VALUE;
FileHandle = CreateFileW (FileNameW ,
dwDesiredAccess, dwDesiredAccess,
dwShareMode, dwShareMode,
lpSecurityAttributes, lpSecurityAttributes,
@ -61,10 +50,6 @@ HANDLE STDCALL CreateFileA (LPCSTR lpFileName,
dwFlagsAndAttributes, dwFlagsAndAttributes,
hTemplateFile); hTemplateFile);
RtlFreeHeap (RtlGetProcessHeap (),
0,
FileNameU.Buffer);
return FileHandle; return FileHandle;
} }

View file

@ -28,30 +28,12 @@ DeleteFileA (
LPCSTR lpFileName LPCSTR lpFileName
) )
{ {
UNICODE_STRING FileNameU; PWCHAR FileNameW;
ANSI_STRING FileName;
BOOL Result; if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
return FALSE;
RtlInitAnsiString (&FileName, return DeleteFileW (FileNameW);
(LPSTR)lpFileName);
/* convert ansi (or oem) string to unicode */
if (bIsFileApiAnsi)
RtlAnsiStringToUnicodeString (&FileNameU,
&FileName,
TRUE);
else
RtlOemStringToUnicodeString (&FileNameU,
&FileName,
TRUE);
Result = DeleteFileW (FileNameU.Buffer);
RtlFreeHeap (RtlGetProcessHeap (),
0,
FileNameU.Buffer);
return Result;
} }

View file

@ -306,52 +306,25 @@ MoveFileWithProgressA (
DWORD dwFlags DWORD dwFlags
) )
{ {
UNICODE_STRING ExistingFileNameU; PWCHAR ExistingFileNameW;
UNICODE_STRING NewFileNameU; PWCHAR NewFileNameW;
ANSI_STRING ExistingFileName; BOOL ret;
ANSI_STRING NewFileName;
BOOL Result; if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
return FALSE;
RtlInitAnsiString (&ExistingFileName, if (!(NewFileNameW= FilenameA2W(lpNewFileName, TRUE)))
(LPSTR)lpExistingFileName); return FALSE;
RtlInitAnsiString (&NewFileName, ret = MoveFileWithProgressW (ExistingFileNameW ,
(LPSTR)lpNewFileName); NewFileNameW,
/* convert ansi (or oem) string to unicode */
if (bIsFileApiAnsi)
{
RtlAnsiStringToUnicodeString (&ExistingFileNameU,
&ExistingFileName,
TRUE);
RtlAnsiStringToUnicodeString (&NewFileNameU,
&NewFileName,
TRUE);
}
else
{
RtlOemStringToUnicodeString (&ExistingFileNameU,
&ExistingFileName,
TRUE);
RtlOemStringToUnicodeString (&NewFileNameU,
&NewFileName,
TRUE);
}
Result = MoveFileWithProgressW (ExistingFileNameU.Buffer,
NewFileNameU.Buffer,
lpProgressRoutine, lpProgressRoutine,
lpData, lpData,
dwFlags); dwFlags);
RtlFreeHeap (RtlGetProcessHeap (), RtlFreeHeap (RtlGetProcessHeap (), 0, NewFileNameW);
0,
ExistingFileNameU.Buffer);
RtlFreeHeap (RtlGetProcessHeap (),
0,
NewFileNameU.Buffer);
return Result; return ret;
} }