Update to 7-Zip 17.00 Beta

This commit is contained in:
Tino Reichardt
2017-04-30 14:14:14 +02:00
parent 54389d6e2f
commit aa5ba75da0
451 changed files with 15746 additions and 8574 deletions

View File

@@ -1,11 +1,13 @@
/* 7zMain.c - Test application for 7z Decoder
2016-05-16 : Igor Pavlov : Public domain */
2017-04-05 : Igor Pavlov : Public domain */
#include "Precomp.h"
#include <stdio.h>
#include <string.h>
#include "../../CpuArch.h"
#include "../../7z.h"
#include "../../7zAlloc.h"
#include "../../7zBuf.h"
@@ -23,7 +25,17 @@
#endif
#endif
static ISzAlloc g_Alloc = { SzAlloc, SzFree };
#define kInputBufSize ((size_t)1 << 18)
static const ISzAlloc g_Alloc = { SzAlloc, SzFree };
static void Print(const char *s)
{
fputs(s, stdout);
}
static int Buf_EnsureSize(CBuf *dest, size_t size)
{
@@ -227,6 +239,7 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
#endif
}
static SRes PrintString(const UInt16 *s)
{
CBuf buf;
@@ -238,12 +251,12 @@ static SRes PrintString(const UInt16 *s)
#endif
);
if (res == SZ_OK)
fputs((const char *)buf.data, stdout);
Print((const char *)buf.data);
Buf_Free(&buf, &g_Alloc);
return res;
}
static void UInt64ToStr(UInt64 value, char *s)
static void UInt64ToStr(UInt64 value, char *s, int numDigits)
{
char temp[32];
int pos = 0;
@@ -253,6 +266,10 @@ static void UInt64ToStr(UInt64 value, char *s)
value /= 10;
}
while (value != 0);
for (numDigits -= pos; numDigits > 0; numDigits--)
*s++ = ' ';
do
*s++ = temp[--pos];
while (pos);
@@ -266,8 +283,10 @@ static char *UIntToStr(char *s, unsigned value, int numDigits)
do
temp[pos++] = (char)('0' + (value % 10));
while (value /= 10);
for (numDigits -= pos; numDigits > 0; numDigits--)
*s++ = '0';
do
*s++ = temp[--pos];
while (pos);
@@ -323,9 +342,16 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
UIntToStr_2(s, sec); s[2] = 0;
}
void PrintError(char *sz)
static void PrintLF()
{
printf("\nERROR: %s\n", sz);
Print("\n");
}
static void PrintError(char *s)
{
Print("\nERROR: ");
Print(s);
PrintLF();
}
static void GetAttribString(UInt32 wa, Bool isDir, char *s)
@@ -343,25 +369,27 @@ static void GetAttribString(UInt32 wa, Bool isDir, char *s)
#endif
}
// #define NUM_PARENTS_MAX 128
int MY_CDECL main(int numargs, char *args[])
{
CFileInStream archiveStream;
CLookToRead lookStream;
CSzArEx db;
SRes res;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
CFileInStream archiveStream;
CLookToRead2 lookStream;
CSzArEx db;
SRes res;
UInt16 *temp = NULL;
size_t tempSize = 0;
// UInt32 parents[NUM_PARENTS_MAX];
printf("\n7z ANSI-C Decoder " MY_VERSION_COPYRIGHT_DATE "\n\n");
Print("\n7z Decoder " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n");
if (numargs == 1)
{
printf(
Print(
"Usage: 7zDec <command> <archive_name>\n\n"
"<Commands>\n"
" e: Extract files from archive (without using directory names)\n"
@@ -370,7 +398,7 @@ int MY_CDECL main(int numargs, char *args[])
" x: eXtract files with full paths\n");
return 0;
}
if (numargs < 3)
{
PrintError("incorrect command");
@@ -381,11 +409,9 @@ int MY_CDECL main(int numargs, char *args[])
g_FileCodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
#endif
allocImp.Alloc = SzAlloc;
allocImp.Free = SzFree;
allocTempImp.Alloc = SzAllocTemp;
allocTempImp.Free = SzFreeTemp;
allocImp = g_Alloc;
allocTempImp = g_Alloc;
#ifdef UNDER_CE
if (InFile_OpenW(&archiveStream.file, L"\test.7z"))
@@ -398,16 +424,31 @@ int MY_CDECL main(int numargs, char *args[])
}
FileInStream_CreateVTable(&archiveStream);
LookToRead_CreateVTable(&lookStream, False);
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);
LookToRead2_CreateVTable(&lookStream, False);
lookStream.buf = NULL;
res = SZ_OK;
{
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
if (!lookStream.buf)
res = SZ_ERROR_MEM;
else
{
lookStream.bufSize = kInputBufSize;
lookStream.realStream = &archiveStream.vt;
LookToRead2_Init(&lookStream);
}
}
CrcGenerateTable();
SzArEx_Init(&db);
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
if (res == SZ_OK)
{
res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp);
}
if (res == SZ_OK)
{
@@ -477,7 +518,7 @@ int MY_CDECL main(int numargs, char *args[])
GetAttribString(SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0, isDir, attr);
fileSize = SzArEx_GetFileSize(&db, i);
UInt64ToStr(fileSize, s);
UInt64ToStr(fileSize, s, 10);
if (SzBitWithVals_Check(&db.MTime, i))
ConvertFileTimeToString(&db.MTime.Vals[i], t);
@@ -489,29 +530,33 @@ int MY_CDECL main(int numargs, char *args[])
t[j] = '\0';
}
printf("%s %s %10s ", t, attr, s);
Print(t);
Print(" ");
Print(attr);
Print(" ");
Print(s);
Print(" ");
res = PrintString(temp);
if (res != SZ_OK)
break;
if (isDir)
printf("/");
printf("\n");
Print("/");
PrintLF();
continue;
}
fputs(testCommand ?
Print(testCommand ?
"Testing ":
"Extracting ",
stdout);
"Extracting ");
res = PrintString(temp);
if (res != SZ_OK)
break;
if (isDir)
printf("/");
Print("/");
else
{
res = SzArEx_Extract(&db, &lookStream.s, i,
res = SzArEx_Extract(&db, &lookStream.vt, i,
&blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed,
&allocImp, &allocTempImp);
@@ -543,7 +588,7 @@ int MY_CDECL main(int numargs, char *args[])
if (isDir)
{
MyCreateDir(destPath);
printf("\n");
PrintLF();
continue;
}
else if (OutFile_OpenUtf16(&outFile, destPath))
@@ -574,20 +619,21 @@ int MY_CDECL main(int numargs, char *args[])
SetFileAttributesW(destPath, db.Attribs.Vals[i]);
#endif
}
printf("\n");
PrintLF();
}
IAlloc_Free(&allocImp, outBuffer);
ISzAlloc_Free(&allocImp, outBuffer);
}
}
SzArEx_Free(&db, &allocImp);
SzFree(NULL, temp);
SzArEx_Free(&db, &allocImp);
ISzAlloc_Free(&allocImp, lookStream.buf);
File_Close(&archiveStream.file);
if (res == SZ_OK)
{
printf("\nEverything is Ok\n");
Print("\nEverything is Ok\n");
return 0;
}
@@ -598,7 +644,11 @@ int MY_CDECL main(int numargs, char *args[])
else if (res == SZ_ERROR_CRC)
PrintError("CRC error");
else
printf("\nERROR #%d\n", res);
{
char s[32];
UInt64ToStr(res, s, 0);
PrintError(s);
}
return 1;
}

View File

@@ -1,5 +1,5 @@
/* 7zipInstall.c - 7-Zip Installer
2016-06-08 : Igor Pavlov : Public domain */
2017-04-04 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -25,9 +25,22 @@
#include "resource.h"
static const WCHAR *k_7zip = L"7-Zip-ZStandard";
static const WCHAR *k_Reg_Software_7zip = L"Software\\7-Zip-ZStandard";
#define wcscat lstrcatW
#define wcslen lstrlenW
#define wcscpy lstrcpyW
#define wcsncpy lstrcpynW
#define kInputBufSize ((size_t)1 << 18)
#define _7ZIP_CUR_VER ((MY_VER_MAJOR << 16) | MY_VER_MINOR)
#define _7ZIP_DLL_VER_COMPAT ((16 << 16) | 3)
static LPCWSTR const k_7zip = L"7-Zip-ZStandard";
static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip-ZStandard";
// #define _64BIT_INSTALLER 1
@@ -43,13 +56,13 @@ static const WCHAR *k_Reg_Software_7zip = L"Software\\7-Zip-ZStandard";
#define k_7zip_with_Ver k_7zip_with_Ver_base
#endif
static const WCHAR *k_7zip_with_Ver_str = k_7zip_with_Ver;
static LPCWSTR const k_7zip_with_Ver_str = k_7zip_with_Ver;
static const WCHAR *k_7zip_Setup = k_7zip_with_Ver L" Setup";
static LPCWSTR const k_7zip_Setup = k_7zip_with_Ver L" Setup";
static const WCHAR *k_Reg_Path = L"Path";
static LPCWSTR const k_Reg_Path = L"Path";
static const WCHAR *k_Reg_Path32 = L"Path"
static LPCWSTR const k_Reg_Path32 = L"Path"
#ifdef _64BIT_INSTALLER
L"64"
#else
@@ -71,8 +84,8 @@ static const WCHAR *k_Reg_Path32 = L"Path"
#define k_7zip_CLSID L"{23170F69-0803-278A-1000-000100020001}"
static const WCHAR *k_Reg_CLSID_7zip = L"CLSID\\" k_7zip_CLSID;
static const WCHAR *k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\\InprocServer32";
static LPCWSTR const k_Reg_CLSID_7zip = L"CLSID\\" k_7zip_CLSID;
static LPCWSTR const k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\\InprocServer32";
#define g_AllUsers True
@@ -107,7 +120,35 @@ static void PrintErrorMessage(const char *s)
MessageBoxW(g_HWND, s2, k_7zip_with_Ver_str, MB_ICONERROR);
}
static WRes MyCreateDir(const WCHAR *name)
static DWORD GetFileVersion(LPCWSTR s)
{
DWORD size = 0;
BYTE *vi = NULL;
DWORD version = 0;
size = GetFileVersionInfoSizeW(s, NULL);
if (size == 0)
return 0;
vi = malloc(size);
if (!vi)
return 0;
if (GetFileVersionInfoW(s, 0, size, vi))
{
VS_FIXEDFILEINFO *fi = NULL;
UINT fiLen = 0;
if (VerQueryValueW(vi, L"\\", (LPVOID *)&fi, &fiLen))
version = fi->dwFileVersionMS;
}
free(vi);
return version;
}
static WRes MyCreateDir(LPCWSTR name)
{
return CreateDirectoryW(name, NULL) ? 0 : GetLastError();
}
@@ -455,7 +496,7 @@ static wchar_t MyWCharLower_Ascii(wchar_t c)
return c;
}
static const WCHAR *FindSubString(const WCHAR *s1, const char *s2)
static LPCWSTR FindSubString(LPCWSTR s1, const char *s2)
{
for (;;)
{
@@ -702,8 +743,8 @@ static void SetShellProgramsGroup(HWND hwndOwner)
#endif
}
static const WCHAR *k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
static const WCHAR *k_7zip_ShellExtension = L"7-Zip Shell Extension";
static LPCWSTR const k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
static LPCWSTR const k_7zip_ShellExtension = L"7-Zip Shell Extension";
static void WriteCLSID()
{
@@ -747,7 +788,7 @@ static void WriteCLSID()
}
}
static const WCHAR * const k_ShellEx_Items[] =
static LPCWSTR const k_ShellEx_Items[] =
{
L"*\\shellex\\ContextMenuHandlers"
, L"Directory\\shellex\\ContextMenuHandlers"
@@ -916,7 +957,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
num = s2 - s;
if (num > MAX_PATH)
num = MAX_PATH;
wcsncpy(path, s, num);
wcsncpy(path, s, (unsigned)num);
RemoveQuotes(path);
}
}
@@ -1059,6 +1100,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
}
}
static Bool GetErrorMessage(DWORD errorCode, WCHAR *message)
{
LPVOID msgBuf;
@@ -1073,10 +1115,12 @@ static Bool GetErrorMessage(DWORD errorCode, WCHAR *message)
return True;
}
static int Install()
{
CFileInStream archiveStream;
CLookToRead lookStream;
CLookToRead2 lookStream;
CSzArEx db;
SRes res = SZ_OK;
@@ -1087,7 +1131,7 @@ static int Install()
ISzAlloc allocTempImp;
WCHAR sfxPath[MAX_PATH + 2];
Bool needReboot = False;
int needRebootLevel = 0;
allocImp.Alloc = SzAlloc;
allocImp.Free = SzFree;
@@ -1127,7 +1171,8 @@ if (res == SZ_OK)
}
FileInStream_CreateVTable(&archiveStream);
LookToRead_CreateVTable(&lookStream, False);
LookToRead2_CreateVTable(&lookStream, False);
lookStream.buf = NULL;
{
// Remove post spaces
@@ -1150,17 +1195,28 @@ if (res == SZ_OK)
winRes = CreateComplexDir();
if (winRes != 0)
res = E_FAIL;
res = SZ_ERROR_FAIL;
pathLen = wcslen(path);
if (res == SZ_OK)
{
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
if (!lookStream.buf)
res = SZ_ERROR_MEM;
else
{
lookStream.bufSize = kInputBufSize;
lookStream.realStream = &archiveStream.vt;
LookToRead2_Init(&lookStream);
}
}
SzArEx_Init(&db);
if (res == SZ_OK)
{
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp);
}
if (res == SZ_OK)
@@ -1222,7 +1278,7 @@ if (res == SZ_OK)
SetWindowTextW(g_InfoLine_HWND, temp);
{
res = SzArEx_Extract(&db, &lookStream.s, i,
res = SzArEx_Extract(&db, &lookStream.vt, i,
&blockIndex, &outBuf, &outBufSize,
&offset, &outSizeProcessed,
&allocImp, &allocTempImp);
@@ -1236,6 +1292,7 @@ if (res == SZ_OK)
size_t j;
// size_t nameStartPos = 0;
UInt32 tempIndex = 0;
int fileLevel = 1 << 2;
WCHAR origPath[MAX_PATH * 2 + 10];
for (j = 0; temp[j] != 0; j++)
@@ -1289,13 +1346,20 @@ if (res == SZ_OK)
break;
}
if (tempIndex != 0
|| FindSubString(temp, "7-zip.dll")
if (tempIndex != 0)
{
tempIndex++;
continue;
}
if (FindSubString(temp, "7-zip.dll")
#ifdef _64BIT_INSTALLER
|| FindSubString(temp, "7-zip32.dll")
#endif
)
{
DWORD ver = GetFileVersion(path);
fileLevel = ((ver < _7ZIP_DLL_VER_COMPAT || ver > _7ZIP_CUR_VER) ? 2 : 1);
tempIndex++;
continue;
}
@@ -1339,7 +1403,7 @@ if (res == SZ_OK)
*/
}
// if (res = S_OK)
// if (res == SZ_OK)
{
processedSize = outSizeProcessed;
winRes = File_Write(&outFile, outBuf + offset, &processedSize);
@@ -1388,14 +1452,14 @@ if (res == SZ_OK)
winRes = GetLastError();
break;
}
needReboot = True;
needRebootLevel |= fileLevel;
#endif
}
}
}
IAlloc_Free(&allocImp, outBuf);
ISzAlloc_Free(&allocImp, outBuf);
if (!g_SilentMode)
SendMessage(g_Progress_HWND, PBM_SETPOS, i, 0);
@@ -1416,6 +1480,8 @@ if (res == SZ_OK)
SzArEx_Free(&db, &allocImp);
ISzAlloc_Free(&allocImp, lookStream.buf);
File_Close(&archiveStream.file);
}
@@ -1425,7 +1491,7 @@ if (res == SZ_OK)
if (res == SZ_OK)
{
if (!g_SilentMode && needReboot)
if (!g_SilentMode && needRebootLevel > 1)
{
if (MessageBoxW(g_HWND, L"You must restart your system to complete the installation.\nRestart now?",
k_7zip_Setup, MB_YESNO | MB_DEFBUTTON2) == IDYES)

View File

@@ -40,9 +40,10 @@ RSC=rc.exe
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -52,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "7zipInstall - Win32 Debug"
@@ -78,7 +79,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF

View File

@@ -1,5 +1,7 @@
PROG = 7zipInstall.exe
LIBS = $(LIBS) version.lib
!IFDEF _64BIT_INSTALLER
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
!ENDIF

View File

@@ -1,5 +1,5 @@
/* 7zipUninstall.c - 7-Zip Uninstaller
2016-05-16 : Igor Pavlov : Public domain */
2017-04-04 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -20,7 +20,7 @@
#define LLL_(quote) L##quote
#define LLL(quote) LLL_(quote)
// static const WCHAR *k_7zip = L"7-Zip";
// static const WCHAR * const k_7zip = L"7-Zip";
// #define _64BIT_INSTALLER 1
@@ -36,13 +36,13 @@
#define k_7zip_with_Ver k_7zip_with_Ver_base
#endif
// static const WCHAR *k_7zip_with_Ver_str = k_7zip_with_Ver;
// static const WCHAR * const k_7zip_with_Ver_str = k_7zip_with_Ver;
static const WCHAR *k_Reg_Software_7zip = L"Software\\7-Zip-ZStandard";
static const WCHAR * const k_Reg_Software_7zip = L"Software\\7-Zip-ZStandard";
static const WCHAR *k_Reg_Path = L"Path";
static const WCHAR * const k_Reg_Path = L"Path";
static const WCHAR *k_Reg_Path32 = L"Path"
static const WCHAR * const k_Reg_Path32 = L"Path"
#ifdef _64BIT_INSTALLER
L"64"
#else
@@ -64,8 +64,8 @@ static const WCHAR *k_Reg_Path32 = L"Path"
#define k_7zip_CLSID L"{23170F69-0803-278A-1000-000100020001}"
static const WCHAR *k_Reg_CLSID_7zip = L"CLSID\\" k_7zip_CLSID;
static const WCHAR *k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\\InprocServer32";
static const WCHAR * const k_Reg_CLSID_7zip = L"CLSID\\" k_7zip_CLSID;
static const WCHAR * const k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\\InprocServer32";
#define g_AllUsers True
@@ -90,7 +90,7 @@ static WCHAR tempPath[MAX_PATH * 2 + 40];
static WCHAR cmdLine[MAX_PATH * 3 + 40];
static WCHAR copyPath[MAX_PATH * 2 + 40];
static const WCHAR *kUninstallExe = L"Uninstall.exe";
static const WCHAR * const kUninstallExe = L"Uninstall.exe";
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
@@ -340,11 +340,11 @@ static const WCHAR * const k_ShellEx_Items[] =
, L"Drive\\shellex\\DragDropHandlers"
};
static const WCHAR *k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
static const WCHAR * const k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
static const WCHAR *k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\7zFM.exe";
static const WCHAR * const k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\7zFM.exe";
#define k_REG_Uninstall L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
static const WCHAR *k_Uninstall_7zip = k_REG_Uninstall L"7-Zip-ZStandard";
static const WCHAR * const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip-ZStandard";
static Bool AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name)
@@ -556,7 +556,7 @@ static BOOL RemoveDir()
#define NUM_FILES (NUM_LANG_TXT_FILES + 1 + 13 + NUM_EXTRA_FILES_64BIT)
static const char *k_Names =
static const char * const k_Names =
"af an ar ast az ba be bg bn br ca co cs cy da de el eo es et eu ext"
" fa fi fr fur fy ga gl gu he hi hr hu hy id io is it ja ka kaa kk ko ku ku-ckb ky"
" lij lt lv mk mn mng mng2 mr ms nb ne nl nn pa-in pl ps pt pt-br ro ru"

View File

@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /FAcs /Yu"Precomp.h" /FD /GF /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"

View File

@@ -1,5 +1,5 @@
/* LzmaUtil.c -- Test application for LZMA compression
2015-11-08 : Igor Pavlov : Public domain */
2017-04-27 : Igor Pavlov : Public domain */
#include "../../Precomp.h"
@@ -7,26 +7,29 @@
#include <stdlib.h>
#include <string.h>
#include "../../CpuArch.h"
#include "../../Alloc.h"
#include "../../7zFile.h"
#include "../../7zVersion.h"
#include "../../LzmaDec.h"
#include "../../LzmaEnc.h"
const char *kCantReadMessage = "Can not read input file";
const char *kCantWriteMessage = "Can not write output file";
const char *kCantAllocateMessage = "Can not allocate memory";
const char *kDataErrorMessage = "Data error";
static const char * const kCantReadMessage = "Can not read input file";
static const char * const kCantWriteMessage = "Can not write output file";
static const char * const kCantAllocateMessage = "Can not allocate memory";
static const char * const kDataErrorMessage = "Data error";
void PrintHelp(char *buffer)
static void PrintHelp(char *buffer)
{
strcat(buffer, "\nLZMA Utility " MY_VERSION_COPYRIGHT_DATE "\n"
"\nUsage: lzma <e|d> inputFile outputFile\n"
" e: encode file\n"
" d: decode file\n");
strcat(buffer,
"\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n"
"Usage: lzma <e|d> inputFile outputFile\n"
" e: encode file\n"
" d: decode file\n");
}
int PrintError(char *buffer, const char *message)
static int PrintError(char *buffer, const char *message)
{
strcat(buffer, "\nError: ");
strcat(buffer, message);
@@ -34,20 +37,22 @@ int PrintError(char *buffer, const char *message)
return 1;
}
int PrintErrorNumber(char *buffer, SRes val)
static int PrintErrorNumber(char *buffer, SRes val)
{
sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);
return 1;
}
int PrintUserError(char *buffer)
static int PrintUserError(char *buffer)
{
return PrintError(buffer, "Incorrect command");
}
#define IN_BUF_SIZE (1 << 16)
#define OUT_BUF_SIZE (1 << 16)
static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream,
UInt64 unpackSize)
{
@@ -101,6 +106,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS
}
}
static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream)
{
UInt64 unpackSize;
@@ -163,7 +169,8 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
return res;
}
int main2(int numArgs, const char *args[], char *rs)
static int main2(int numArgs, const char *args[], char *rs)
{
CFileSeqInStream inStream;
CFileOutStream outStream;
@@ -215,11 +222,11 @@ int main2(int numArgs, const char *args[], char *rs)
{
UInt64 fileSize;
File_GetLength(&inStream.file, &fileSize);
res = Encode(&outStream.s, &inStream.s, fileSize, rs);
res = Encode(&outStream.vt, &inStream.vt, fileSize, rs);
}
else
{
res = Decode(&outStream.s, useOutFile ? &inStream.s : NULL);
res = Decode(&outStream.vt, useOutFile ? &inStream.vt : NULL);
}
if (useOutFile)
@@ -241,6 +248,7 @@ int main2(int numArgs, const char *args[], char *rs)
return 0;
}
int MY_CDECL main(int numArgs, const char *args[])
{
char rs[800] = { 0 };

View File

@@ -1,5 +1,5 @@
/* SfxSetup.c - 7z SFX Setup
2016-05-16 : Igor Pavlov : Public domain */
2017-04-04 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -24,6 +24,8 @@
#define k_EXE_ExtIndex 2
#define kInputBufSize ((size_t)1 << 18)
static const char * const kExts[] =
{
"bat"
@@ -238,7 +240,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#endif
{
CFileInStream archiveStream;
CLookToRead lookStream;
CLookToRead2 lookStream;
CSzArEx db;
SRes res = SZ_OK;
ISzAlloc allocImp;
@@ -275,7 +277,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
allocTempImp.Free = SzFreeTemp;
FileInStream_CreateVTable(&archiveStream);
LookToRead_CreateVTable(&lookStream, False);
LookToRead2_CreateVTable(&lookStream, False);
lookStream.buf = NULL;
winRes = GetModuleFileNameW(NULL, sfxPath, MAX_PATH);
if (winRes == 0 || winRes > MAX_PATH)
@@ -376,14 +379,22 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
if (res == SZ_OK)
{
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
if (!lookStream.buf)
res = SZ_ERROR_MEM;
else
{
lookStream.bufSize = kInputBufSize;
lookStream.realStream = &archiveStream.vt;
LookToRead2_Init(&lookStream);
}
}
SzArEx_Init(&db);
if (res == SZ_OK)
{
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp);
}
if (res == SZ_OK)
@@ -411,7 +422,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
SzArEx_GetFileNameUtf16(&db, i, temp);
{
res = SzArEx_Extract(&db, &lookStream.s, i,
res = SzArEx_Extract(&db, &lookStream.vt, i,
&blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed,
&allocImp, &allocTempImp);
@@ -522,10 +533,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
temp[j] = CHAR_PATH_SEPARATOR;
}
}
IAlloc_Free(&allocImp, outBuffer);
ISzAlloc_Free(&allocImp, outBuffer);
}
SzArEx_Free(&db, &allocImp);
ISzAlloc_Free(&allocImp, lookStream.buf);
File_Close(&archiveStream.file);
if (res == SZ_OK)