Browse Source

Support Unicode archive names.

Martijn Laan 11 months ago
parent
commit
3fa5eb6809

+ 8 - 11
Components/Lzma2/Util/7z/7zMain.c

@@ -5,6 +5,7 @@
    -Don't include <stdio.h> but instead define fputs' prototype and a stdout dummy, allowing
    -Don't include <stdio.h> but instead define fputs' prototype and a stdout dummy, allowing
     the test application code to be embedded in another application (which should implement fputs)
     the test application code to be embedded in another application (which should implement fputs)
    -Use CP_UTF8 in PrintString
    -Use CP_UTF8 in PrintString
+   -Change main to mainW to support Unicode archive names
    Otherwise unchanged */
    Otherwise unchanged */
 
 
 #include "Precomp.h"
 #include "Precomp.h"
@@ -550,7 +551,7 @@ static void GetAttribString(UInt32 wa, BoolInt isDir, char *s)
 
 
 // #define NUM_PARENTS_MAX 128
 // #define NUM_PARENTS_MAX 128
 
 
-int Z7_CDECL main(int numargs, char *args[])
+int Z7_CDECL mainW(int numargs, WCHAR *args[])
 {
 {
   ISzAlloc allocImp;
   ISzAlloc allocImp;
   ISzAlloc allocTempImp;
   ISzAlloc allocTempImp;
@@ -594,11 +595,7 @@ int Z7_CDECL main(int numargs, char *args[])
 
 
   {
   {
     WRes wres =
     WRes wres =
-    #ifdef UNDER_CE
-      InFile_OpenW(&archiveStream.file, L"\test.7z"); // change it
-    #else
-      InFile_Open(&archiveStream.file, args[2]);
-    #endif
+      InFile_OpenW(&archiveStream.file, args[2]);
     if (wres != 0)
     if (wres != 0)
     {
     {
       PrintError_WRes("cannot open input file", wres);
       PrintError_WRes("cannot open input file", wres);
@@ -636,13 +633,13 @@ int Z7_CDECL main(int numargs, char *args[])
   
   
   if (res == SZ_OK)
   if (res == SZ_OK)
   {
   {
-    char *command = args[1];
+    WCHAR *command = args[1];
     int listCommand = 0, testCommand = 0, fullPaths = 0;
     int listCommand = 0, testCommand = 0, fullPaths = 0;
     
     
-    if (strcmp(command, "l") == 0) listCommand = 1;
-    else if (strcmp(command, "t") == 0) testCommand = 1;
-    else if (strcmp(command, "e") == 0) { }
-    else if (strcmp(command, "x") == 0) { fullPaths = 1; }
+    if (wcscmp(command, L"l") == 0) listCommand = 1;
+    else if (wcscmp(command, L"t") == 0) testCommand = 1;
+    else if (wcscmp(command, L"e") == 0) { }
+    else if (wcscmp(command, L"x") == 0) { fullPaths = 1; }
     else
     else
     {
     {
       PrintError("incorrect command");
       PrintError("incorrect command");

+ 5 - 5
Projects/Src/Compression.SevenZipDecoder.pas

@@ -12,7 +12,7 @@ unit Compression.SevenZipDecoder;
 
 
 interface
 interface
 
 
-procedure SevenZipDecode(const FileName: AnsiString; const DestDir: String;
+procedure SevenZipDecode(const FileName, DestDir: String;
   const FullPaths: Boolean);
   const FullPaths: Boolean);
 
 
 implementation
 implementation
@@ -22,7 +22,7 @@ uses
 
 
 {$L Src\Compression.SevenZipDecoder\7ZipDecode\IS7ZipDec.obj}
 {$L Src\Compression.SevenZipDecoder\7ZipDecode\IS7ZipDec.obj}
 
 
-function IS_7ZipDec(const fileName: PAnsiChar; const fullPaths: Bool): Integer; cdecl; external name '_IS_7ZipDec';
+function IS_7ZipDec(const fileName: PChar; const fullPaths: Bool): Integer; cdecl; external name '_IS_7ZipDec';
 
 
 {.$DEFINE VISUALSTUDIO}
 {.$DEFINE VISUALSTUDIO}
 
 
@@ -60,7 +60,7 @@ begin
     VirtualFree(address, 0, MEM_RELEASE);
     VirtualFree(address, 0, MEM_RELEASE);
 end;
 end;
 
 
-function _strcmp(string1, string2: PAnsiChar): Integer; cdecl;
+function _wcscmp(string1, string2: PChar): Integer; cdecl;
 begin
 begin
   Result := StrComp(string1, string2);
   Result := StrComp(string1, string2);
 end;
 end;
@@ -71,12 +71,12 @@ begin
   Result := 1;
   Result := 1;
 end;
 end;
 
 
-procedure SevenZipDecode(const FileName: AnsiString; const DestDir: String;
+procedure SevenZipDecode(const FileName, DestDir: String;
   const FullPaths: Boolean);
   const FullPaths: Boolean);
 begin
 begin
   var SaveCurDir := GetCurrentDir;
   var SaveCurDir := GetCurrentDir;
   SetCurrentDir(DestDir);
   SetCurrentDir(DestDir);
-  IS_7ZipDec(PAnsiChar(FileName), FullPaths);
+  IS_7ZipDec(PChar(FileName), FullPaths);
   SetCurrentDir(SaveCurDir);
   SetCurrentDir(SaveCurDir);
 end;
 end;
 
 

+ 5 - 5
Projects/Src/Compression.SevenZipDecoder/7ZipDecode/IS7ZipDec.c

@@ -20,11 +20,11 @@
 #include "../../../../Components/Lzma2/LzmaDec.c"
 #include "../../../../Components/Lzma2/LzmaDec.c"
 #include "../../../../Components/Lzma2/Lzma2Dec.c"
 #include "../../../../Components/Lzma2/Lzma2Dec.c"
 
 
-int IS_7ZipDec(char *fileName, BOOL fullPaths)
+int IS_7ZipDec(WCHAR *fileName, BOOL fullPaths)
 {
 {
-  char* args[3];
-  args[0] = "";
-  args[1] = fullPaths?"x":"e";
+  WCHAR* args[3];
+  args[0] = L"";
+  args[1] = fullPaths?L"x":L"e";
   args[2] = fileName;
   args[2] = fileName;
-  return main(3, args);
+  return mainW(3, args);
 }
 }

BIN
Projects/Src/Compression.SevenZipDecoder/7ZipDecode/IS7ZipDec.obj