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
)
{
ANSI_STRING FileNameA;
UNICODE_STRING FileName;
NTSTATUS Status;
BOOL Ret;
PWCHAR ApplicationNameW;
if(!lpApplicationName || !lpBinaryType)
{
@ -315,22 +312,10 @@ GetBinaryTypeA (
return FALSE;
}
RtlInitAnsiString(&FileNameA, (LPSTR)lpApplicationName);
if (!(ApplicationNameW = FilenameA2W(lpApplicationName, FALSE)))
return FALSE;
if(bIsFileApiAnsi)
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;
return GetBinaryTypeW(ApplicationNameW, lpBinaryType);
}
/* EOF */

View file

@ -321,40 +321,18 @@ CopyFileExA (
DWORD dwCopyFlags
)
{
UNICODE_STRING ExistingFileNameU;
UNICODE_STRING NewFileNameU;
ANSI_STRING ExistingFileName;
ANSI_STRING NewFileName;
PWCHAR ExistingFileNameW;
PWCHAR NewFileNameW;
BOOL Result;
RtlInitAnsiString (&ExistingFileName,
(LPSTR)lpExistingFileName);
if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
return FALSE;
RtlInitAnsiString (&NewFileName,
(LPSTR)lpNewFileName);
if (!(NewFileNameW = FilenameA2W(lpNewFileName, TRUE)))
return FALSE;
/* 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 = CopyFileExW (ExistingFileNameU.Buffer,
NewFileNameU.Buffer,
Result = CopyFileExW (ExistingFileNameW ,
NewFileNameW ,
lpProgressRoutine,
lpData,
pbCancel,
@ -362,10 +340,7 @@ CopyFileExA (
RtlFreeHeap (RtlGetProcessHeap (),
0,
ExistingFileNameU.Buffer);
RtlFreeHeap (RtlGetProcessHeap (),
0,
NewFileNameU.Buffer);
NewFileNameW);
return Result;
}

View file

@ -34,26 +34,15 @@ HANDLE STDCALL CreateFileA (LPCSTR lpFileName,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
UNICODE_STRING FileNameU;
ANSI_STRING FileName;
PWCHAR FileNameW;
HANDLE FileHandle;
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,
dwShareMode,
lpSecurityAttributes,
@ -61,10 +50,6 @@ HANDLE STDCALL CreateFileA (LPCSTR lpFileName,
dwFlagsAndAttributes,
hTemplateFile);
RtlFreeHeap (RtlGetProcessHeap (),
0,
FileNameU.Buffer);
return FileHandle;
}

View file

@ -28,30 +28,12 @@ DeleteFileA (
LPCSTR lpFileName
)
{
UNICODE_STRING FileNameU;
ANSI_STRING FileName;
BOOL Result;
PWCHAR FileNameW;
if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
return FALSE;
RtlInitAnsiString (&FileName,
(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;
return DeleteFileW (FileNameW);
}

View file

@ -306,52 +306,25 @@ MoveFileWithProgressA (
DWORD dwFlags
)
{
UNICODE_STRING ExistingFileNameU;
UNICODE_STRING NewFileNameU;
ANSI_STRING ExistingFileName;
ANSI_STRING NewFileName;
BOOL Result;
PWCHAR ExistingFileNameW;
PWCHAR NewFileNameW;
BOOL ret;
if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
return FALSE;
RtlInitAnsiString (&ExistingFileName,
(LPSTR)lpExistingFileName);
if (!(NewFileNameW= FilenameA2W(lpNewFileName, TRUE)))
return FALSE;
RtlInitAnsiString (&NewFileName,
(LPSTR)lpNewFileName);
/* 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,
ret = MoveFileWithProgressW (ExistingFileNameW ,
NewFileNameW,
lpProgressRoutine,
lpData,
dwFlags);
RtlFreeHeap (RtlGetProcessHeap (),
0,
ExistingFileNameU.Buffer);
RtlFreeHeap (RtlGetProcessHeap (),
0,
NewFileNameU.Buffer);
RtlFreeHeap (RtlGetProcessHeap (), 0, NewFileNameW);
return Result;
return ret;
}