GetBinaryTypeA, CopyFileExA, CreateFileA, DeleteFileA, MoveFileWithProgressA: Use...
authorGunnar Dalsnes <hardon@online.no>
Sun, 20 Mar 2005 17:39:11 +0000 (17:39 +0000)
committerGunnar Dalsnes <hardon@online.no>
Sun, 20 Mar 2005 17:39:11 +0000 (17:39 +0000)
svn path=/trunk/; revision=14227

reactos/lib/kernel32/file/bintype.c
reactos/lib/kernel32/file/copy.c
reactos/lib/kernel32/file/create.c
reactos/lib/kernel32/file/delete.c
reactos/lib/kernel32/file/move.c

index 31d8ddc..48a5bde 100644 (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 */
index 6ce97ce..f998feb 100644 (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);
-
-       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 = CopyFileExW (ExistingFileNameU.Buffer,
-                             NewFileNameU.Buffer,
+   if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
+      return FALSE;
+
+   if (!(NewFileNameW = FilenameA2W(lpNewFileName, TRUE)))
+      return FALSE;
+
+   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;
 }
index 811c7ae..eb53592 100644 (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;
 }
 
index 59131a9..b643c84 100644 (file)
@@ -28,30 +28,12 @@ DeleteFileA (
        LPCSTR  lpFileName
        )
 {
-       UNICODE_STRING FileNameU;
-       ANSI_STRING FileName;
-       BOOL Result;
-
-       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;
+       PWCHAR FileNameW;
+   
+   if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
+      return FALSE;
+
+       return DeleteFileW (FileNameW);
 }
 
 
index c4d7215..a7ae400 100644 (file)
@@ -306,52 +306,25 @@ MoveFileWithProgressA (
        DWORD                   dwFlags
        )
 {
-       UNICODE_STRING ExistingFileNameU;
-       UNICODE_STRING NewFileNameU;
-       ANSI_STRING ExistingFileName;
-       ANSI_STRING NewFileName;
-       BOOL Result;
-
-       RtlInitAnsiString (&ExistingFileName,
-                          (LPSTR)lpExistingFileName);
-
-       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,
+       PWCHAR ExistingFileNameW;
+   PWCHAR NewFileNameW;
+       BOOL ret;
+   
+   if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE)))
+      return FALSE;
+
+   if (!(NewFileNameW= FilenameA2W(lpNewFileName, TRUE)))
+      return FALSE;
+
+   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;
 }