GetBinaryTypeA, CopyFileExA, CreateFileA, DeleteFileA, MoveFileWithProgressA: Use common A2W conv. routines
Modified: trunk/reactos/lib/kernel32/file/bintype.c
Modified: trunk/reactos/lib/kernel32/file/copy.c
Modified: trunk/reactos/lib/kernel32/file/create.c
Modified: trunk/reactos/lib/kernel32/file/delete.c
Modified: trunk/reactos/lib/kernel32/file/move.c

Modified: trunk/reactos/lib/kernel32/file/bintype.c
--- trunk/reactos/lib/kernel32/file/bintype.c	2005-03-20 17:26:58 UTC (rev 14226)
+++ trunk/reactos/lib/kernel32/file/bintype.c	2005-03-20 17:39:11 UTC (rev 14227)
@@ -304,10 +304,7 @@
     LPDWORD lpBinaryType
     )
 {
-  ANSI_STRING FileNameA;
-  UNICODE_STRING FileName;
-  NTSTATUS Status;
-  BOOL Ret;
+  PWCHAR ApplicationNameW;
   
   if(!lpApplicationName || !lpBinaryType)
   {
@@ -315,22 +312,10 @@
     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 */

Modified: trunk/reactos/lib/kernel32/file/copy.c
--- trunk/reactos/lib/kernel32/file/copy.c	2005-03-20 17:26:58 UTC (rev 14226)
+++ trunk/reactos/lib/kernel32/file/copy.c	2005-03-20 17:39:11 UTC (rev 14227)
@@ -321,40 +321,18 @@
 	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 @@
 
 	RtlFreeHeap (RtlGetProcessHeap (),
 	             0,
-	             ExistingFileNameU.Buffer);
-	RtlFreeHeap (RtlGetProcessHeap (),
-	             0,
-	             NewFileNameU.Buffer);
+                NewFileNameW);
 
 	return Result;
 }

Modified: trunk/reactos/lib/kernel32/file/create.c
--- trunk/reactos/lib/kernel32/file/create.c	2005-03-20 17:26:58 UTC (rev 14226)
+++ trunk/reactos/lib/kernel32/file/create.c	2005-03-20 17:39:11 UTC (rev 14227)
@@ -34,26 +34,15 @@
 			    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 @@
 			     dwFlagsAndAttributes,
 			     hTemplateFile);
    
-   RtlFreeHeap (RtlGetProcessHeap (),
-		0,
-		FileNameU.Buffer);
-   
    return FileHandle;
 }
 

Modified: trunk/reactos/lib/kernel32/file/delete.c
--- trunk/reactos/lib/kernel32/file/delete.c	2005-03-20 17:26:58 UTC (rev 14226)
+++ trunk/reactos/lib/kernel32/file/delete.c	2005-03-20 17:39:11 UTC (rev 14227)
@@ -28,30 +28,12 @@
 	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);
 }
 
 

Modified: trunk/reactos/lib/kernel32/file/move.c
--- trunk/reactos/lib/kernel32/file/move.c	2005-03-20 17:26:58 UTC (rev 14226)
+++ trunk/reactos/lib/kernel32/file/move.c	2005-03-20 17:39:11 UTC (rev 14227)
@@ -306,52 +306,25 @@
 	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;
 }