feat(25.01): add bundle wrapper directory with NSIS sources and vendor symlinks
Mirror the 26.00-bundle / 26.01-bundle approach for 25.01:
- versions/25.01-bundle/CPP/7zip/Bundles/Nsis7z/: project-owned NSIS plugin
wrapper sources (api.h, nsis7z.cpp, pluginapi.*, resource.*, StdAfx*,
Nsis7z.sln, Nsis7z.vcxproj, Nsis7z.vcxproj.filters, Nsis7z_vs2026.vcxproj).
- versions/25.01-bundle/CPP/7zip/UI/NSIS/: NSIS UI sources; StdAfx.h patched
to use relative include path and MinGW-compatible Windows.h guard (the
upstream 25.01 file used an absolute path incompatible with the bundle layout).
- versions/25.01-bundle/CPP/7zip/LzmaDec_gcc.mak: forwarding stub.
- versions/25.01-bundle/{C,Asm} and CPP sub-trees: symlinks into versions/25.01/.
- tools/linux/setup_25_01_bundle_symlinks.py: idempotent symlink-recreation script.
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Agent
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Client7z
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Common
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Console
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Explorer
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/Far
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/FileManager
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/GUI
|
||||
@@ -0,0 +1,163 @@
|
||||
// ExtractCallbackConsole.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "ExtractCallbackConsole.h"
|
||||
#include "UserInputUtils2.h"
|
||||
#include "NSISBreak.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/TimeUtils.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/ErrorMsg.h"
|
||||
#include "Windows/PropVariantConv.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
#include "../Common/ExtractingFilePath.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
|
||||
extern HWND g_hwndProgress;
|
||||
|
||||
void CExtractCallbackConsole::UpdateProgress()
|
||||
{
|
||||
// Prima controlla se c'è il callback con filename (nuova funzione)
|
||||
if (ProgressWithFileHandler != NULL)
|
||||
{
|
||||
if (completedSize != -1 || totalSize > 0)
|
||||
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
||||
else
|
||||
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
||||
}
|
||||
// Altrimenti usa il callback originale (per compatibilità)
|
||||
else if (ProgressHandler != NULL)
|
||||
{
|
||||
if (completedSize != -1 || totalSize > 0)
|
||||
ProgressHandler(completedSize, totalSize);
|
||||
else
|
||||
ProgressHandler(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
||||
{
|
||||
totalSize = val;
|
||||
UpdateProgress();
|
||||
if (NNSISBreak::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
||||
{
|
||||
completedSize = *val;
|
||||
UpdateProgress();
|
||||
if (NNSISBreak::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
||||
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
||||
Int32 *answer)
|
||||
{
|
||||
*answer = NOverwriteAnswer::kYesToAll;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position)
|
||||
{
|
||||
// Memorizza il nome del file corrente per passarlo al callback
|
||||
CurrentFileName = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
|
||||
{
|
||||
NumFileErrorsInCurrentArchive++;
|
||||
NumFileErrors++;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
|
||||
{
|
||||
switch(opRes)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
NumFileErrorsInCurrentArchive++;
|
||||
NumFileErrors++;
|
||||
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
|
||||
HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
|
||||
{
|
||||
PasswordIsDefined = true;
|
||||
Password = password;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
Password = GetPassword(OutStream);
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
||||
{
|
||||
NumArchives++;
|
||||
NumFileErrorsInCurrentArchive = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackConsole::OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
||||
{
|
||||
if (result != S_OK)
|
||||
{
|
||||
NumArchiveErrors++;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackConsole::ThereAreNoFiles()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
|
||||
{
|
||||
if (result == S_OK)
|
||||
{
|
||||
if (NumFileErrorsInCurrentArchive != 0)
|
||||
{
|
||||
NumArchiveErrors++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
NumArchiveErrors++;
|
||||
if (result == E_ABORT || result == ERROR_DISK_FULL)
|
||||
return result;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// ExtractCallbackConsole.h
|
||||
// NSIS version adapted for 7-Zip 25.01 API
|
||||
|
||||
#ifndef __EXTRACTCALLBACKCONSOLE_H
|
||||
#define __EXTRACTCALLBACKCONSOLE_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/StdOutStream.h"
|
||||
#include "../../Common/FileStreams.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Archive/IArchive.h"
|
||||
#include "../Common/ArchiveExtractCallback.h"
|
||||
#include "../Console/OpenCallbackConsole.h"
|
||||
|
||||
typedef void (*ExtractProgressHandler)(UInt64 completedSize, UInt64 totalSize);
|
||||
typedef void (*ExtractProgressWithFileHandler)(UInt64 completedSize, UInt64 totalSize, const wchar_t *fileName);
|
||||
|
||||
class CExtractCallbackConsole Z7_final:
|
||||
public IFolderArchiveExtractCallback,
|
||||
public IExtractCallbackUI,
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
public ICryptoGetTextPassword,
|
||||
#endif
|
||||
public COpenCallbackConsole,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_COM_QI_BEGIN2(IFolderArchiveExtractCallback)
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
Z7_COM_QI_ENTRY(ICryptoGetTextPassword)
|
||||
#endif
|
||||
Z7_COM_QI_END
|
||||
Z7_COM_ADDREF_RELEASE
|
||||
|
||||
// IProgress
|
||||
Z7_IFACE_COM7_IMP(IProgress)
|
||||
|
||||
// IFolderArchiveExtractCallback
|
||||
Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback)
|
||||
|
||||
// IExtractCallbackUI (non-COM interface)
|
||||
Z7_IFACE_IMP(IExtractCallbackUI)
|
||||
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
Z7_IFACE_COM7_IMP(ICryptoGetTextPassword)
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
#endif
|
||||
|
||||
UInt64 NumArchives;
|
||||
UInt64 NumArchiveErrors;
|
||||
UInt64 NumFileErrors;
|
||||
UInt64 NumFileErrorsInCurrentArchive;
|
||||
|
||||
CStdOutStream *OutStream;
|
||||
|
||||
UInt64 totalSize, completedSize, lastVal;
|
||||
|
||||
ExtractProgressHandler ProgressHandler;
|
||||
ExtractProgressWithFileHandler ProgressWithFileHandler;
|
||||
UString CurrentFileName;
|
||||
|
||||
CExtractCallbackConsole():
|
||||
PasswordIsDefined(false),
|
||||
NumArchives(0),
|
||||
NumArchiveErrors(0),
|
||||
NumFileErrors(0),
|
||||
NumFileErrorsInCurrentArchive(0),
|
||||
OutStream(NULL),
|
||||
totalSize((UInt64)(Int64)-1),
|
||||
completedSize(0),
|
||||
lastVal(0),
|
||||
ProgressHandler(NULL),
|
||||
ProgressWithFileHandler(NULL)
|
||||
{}
|
||||
|
||||
void Init()
|
||||
{
|
||||
NumArchives = 0;
|
||||
NumArchiveErrors = 0;
|
||||
NumFileErrors = 0;
|
||||
NumFileErrorsInCurrentArchive = 0;
|
||||
|
||||
totalSize = (UInt64)(Int64)-1;
|
||||
completedSize = 0;
|
||||
lastVal = 0;
|
||||
ProgressHandler = NULL;
|
||||
ProgressWithFileHandler = NULL;
|
||||
}
|
||||
|
||||
void UpdateProgress();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,313 @@
|
||||
// Main.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "Common/MyInitGuid.h"
|
||||
|
||||
#include "Common/CommandLineParser.h"
|
||||
#include "Common/MyException.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StdOutStream.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/ErrorMsg.h"
|
||||
#ifdef _WIN32
|
||||
#include "Windows/MemoryLock.h"
|
||||
#endif
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "../Common/UpdateAction.h"
|
||||
#include "../Common/Update.h"
|
||||
#include "../Common/Extract.h"
|
||||
#include "../Common/ArchiveCommandLine.h"
|
||||
#include "../Common/ExitCode.h"
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#include "../Common/LoadCodecs.h"
|
||||
#endif
|
||||
|
||||
//#include "../../Compress/LZMA_Alone/LzmaBenchCon.h"
|
||||
|
||||
#include "../Console/OpenCallbackConsole.h"
|
||||
#include "ExtractCallbackConsole.h"
|
||||
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Alloc.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NCommandLineParser;
|
||||
|
||||
HINSTANCE g_hInstance = 0;
|
||||
|
||||
// ---------------------------
|
||||
// exception messages
|
||||
|
||||
#ifndef _WIN32
|
||||
static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
|
||||
{
|
||||
parts.Clear();
|
||||
for(int i = 0; i < numArguments; i++)
|
||||
{
|
||||
UString s = MultiByteToUnicodeString(arguments[i]);
|
||||
parts.Add(s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
static void PrintString(CStdOutStream &stdStream, const AString &s, int size)
|
||||
{
|
||||
int len = s.Length();
|
||||
stdStream << s;
|
||||
for (int i = len; i < size; i++)
|
||||
stdStream << ' ';
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline char GetHex(Byte value)
|
||||
{
|
||||
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void SwitchFileAPIEncoding(BOOL ansi)
|
||||
{
|
||||
if (ansi)
|
||||
{
|
||||
SetFileApisToOEM();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFileApisToANSI();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int DoExtractArchive(UString archive, UString targetDir, bool overwrite, bool extractPaths, ExtractProgressHandler epc, const UStringVector& skipPatterns)
|
||||
{
|
||||
CCodecs *codecs = new CCodecs;
|
||||
CMyComPtr<IUnknown> compressCodecsInfo = codecs;
|
||||
HRESULT result = codecs->Load();
|
||||
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
if (codecs->Formats.Size() == 0) throw -1;
|
||||
|
||||
CIntVector formatIndices;
|
||||
|
||||
if (!codecs->FindFormatForArchiveType(L"7z", formatIndices))
|
||||
{
|
||||
throw -1;
|
||||
}
|
||||
|
||||
BOOL bApisAreAnsi = AreFileApisANSI();
|
||||
|
||||
#ifdef _WIN32
|
||||
if (bApisAreAnsi)
|
||||
SwitchFileAPIEncoding(bApisAreAnsi);
|
||||
#endif
|
||||
|
||||
CExtractCallbackConsole *ecs = new CExtractCallbackConsole();
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
|
||||
ecs->Init();
|
||||
ecs->ProgressHandler = epc; // Imposta DOPO Init()
|
||||
|
||||
COpenCallbackConsole openCallback;
|
||||
|
||||
CExtractOptions eo;
|
||||
eo.StdOutMode = false;
|
||||
eo.PathMode = extractPaths?NExtract::NPathMode::kCurPaths:NExtract::NPathMode::kNoPaths;
|
||||
eo.TestMode = false;
|
||||
eo.OverwriteMode = overwrite?NExtract::NOverwriteMode::kOverwrite:NExtract::NOverwriteMode::kSkip;
|
||||
eo.OutputDir = targetDir;
|
||||
eo.YesToAll = true;
|
||||
#ifdef COMPRESS_MT
|
||||
CObjectVector<CProperty> prp;
|
||||
eo.Properties = prp;
|
||||
#endif
|
||||
UString errorMessage;
|
||||
CDecompressStat stat;
|
||||
NWildcard::CCensor wildcardCensor;
|
||||
NWildcard::CCensorPathProps props;
|
||||
props.Recursive = true;
|
||||
props.WildcardMatching = true;
|
||||
wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, true, L"*", props);
|
||||
for (unsigned i = 0; i < skipPatterns.Size(); i++)
|
||||
{
|
||||
const UString &p = skipPatterns[i];
|
||||
if (p.IsEmpty()) continue;
|
||||
// Keep only single-name patterns: multi-segment ones land in a separate Pair
|
||||
// and would be silently ignored by Pairs.Front().Head below.
|
||||
if (p.Find(L'\\') >= 0 || p.Find(L'/') >= 0) continue;
|
||||
wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, false, p, props);
|
||||
}
|
||||
UStringVector ArchivePathsSorted;
|
||||
UStringVector ArchivePathsFullSorted;
|
||||
ArchivePathsSorted.Add(archive);
|
||||
UString fullPath;
|
||||
NFile::NDir::MyGetFullPathName(archive, fullPath);
|
||||
ArchivePathsFullSorted.Add(fullPath);
|
||||
|
||||
UStringVector v1, v2;
|
||||
v1.Add(fs2us(archive));
|
||||
v2.Add(fs2us(archive));
|
||||
const NWildcard::CCensorNode &wildcardCensorHead =
|
||||
wildcardCensor.Pairs.Front().Head;
|
||||
|
||||
result = Extract(
|
||||
codecs, CObjectVector<COpenType>(), CIntVector(),
|
||||
v1, v2,
|
||||
wildcardCensorHead,
|
||||
eo, ecs, ecs, ecs,
|
||||
#ifndef Z7_SFX
|
||||
NULL, // hash
|
||||
#endif
|
||||
errorMessage, stat);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (bApisAreAnsi)
|
||||
SwitchFileAPIEncoding(!bApisAreAnsi);
|
||||
#endif
|
||||
|
||||
|
||||
if (!errorMessage.IsEmpty())
|
||||
{
|
||||
if (result == S_OK)
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
|
||||
{
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DoExtractArchiveWithFile(UString archive, UString targetDir, bool overwrite, bool extractPaths, ExtractProgressWithFileHandler epc, const UStringVector& skipPatterns)
|
||||
{
|
||||
CCodecs *codecs = new CCodecs;
|
||||
CMyComPtr<IUnknown> compressCodecsInfo = codecs;
|
||||
HRESULT result = codecs->Load();
|
||||
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
if (codecs->Formats.Size() == 0) throw -1;
|
||||
|
||||
CIntVector formatIndices;
|
||||
|
||||
if (!codecs->FindFormatForArchiveType(L"7z", formatIndices))
|
||||
{
|
||||
throw -1;
|
||||
}
|
||||
|
||||
BOOL bApisAreAnsi = AreFileApisANSI();
|
||||
|
||||
#ifdef _WIN32
|
||||
if (bApisAreAnsi)
|
||||
SwitchFileAPIEncoding(bApisAreAnsi);
|
||||
#endif
|
||||
|
||||
CExtractCallbackConsole *ecs = new CExtractCallbackConsole();
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
|
||||
ecs->Init();
|
||||
ecs->ProgressWithFileHandler = epc; // Imposta DOPO Init() per evitare che venga resettato
|
||||
|
||||
COpenCallbackConsole openCallback;
|
||||
|
||||
CExtractOptions eo;
|
||||
eo.StdOutMode = false;
|
||||
eo.PathMode = extractPaths?NExtract::NPathMode::kCurPaths:NExtract::NPathMode::kNoPaths;
|
||||
eo.TestMode = false;
|
||||
eo.OverwriteMode = overwrite?NExtract::NOverwriteMode::kOverwrite:NExtract::NOverwriteMode::kSkip;
|
||||
eo.OutputDir = targetDir;
|
||||
eo.YesToAll = true;
|
||||
#ifdef COMPRESS_MT
|
||||
CObjectVector<CProperty> prp;
|
||||
eo.Properties = prp;
|
||||
#endif
|
||||
UString errorMessage;
|
||||
CDecompressStat stat;
|
||||
NWildcard::CCensor wildcardCensor;
|
||||
NWildcard::CCensorPathProps props;
|
||||
props.Recursive = true;
|
||||
props.WildcardMatching = true;
|
||||
wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, true, L"*", props);
|
||||
for (unsigned i = 0; i < skipPatterns.Size(); i++)
|
||||
{
|
||||
const UString &p = skipPatterns[i];
|
||||
if (p.IsEmpty()) continue;
|
||||
// Keep only single-name patterns: multi-segment ones land in a separate Pair
|
||||
// and would be silently ignored by Pairs.Front().Head below.
|
||||
if (p.Find(L'\\') >= 0 || p.Find(L'/') >= 0) continue;
|
||||
wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, false, p, props);
|
||||
}
|
||||
UStringVector ArchivePathsSorted;
|
||||
UStringVector ArchivePathsFullSorted;
|
||||
ArchivePathsSorted.Add(archive);
|
||||
UString fullPath;
|
||||
NFile::NDir::MyGetFullPathName(archive, fullPath);
|
||||
ArchivePathsFullSorted.Add(fullPath);
|
||||
|
||||
UStringVector v1, v2;
|
||||
v1.Add(fs2us(archive));
|
||||
v2.Add(fs2us(archive));
|
||||
const NWildcard::CCensorNode &wildcardCensorHead =
|
||||
wildcardCensor.Pairs.Front().Head;
|
||||
|
||||
result = Extract(
|
||||
codecs, CObjectVector<COpenType>(), CIntVector(),
|
||||
v1, v2,
|
||||
wildcardCensorHead,
|
||||
eo, ecs, ecs, ecs,
|
||||
#ifndef Z7_SFX
|
||||
NULL, // hash
|
||||
#endif
|
||||
errorMessage, stat);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (bApisAreAnsi)
|
||||
SwitchFileAPIEncoding(!bApisAreAnsi);
|
||||
#endif
|
||||
|
||||
|
||||
if (!errorMessage.IsEmpty())
|
||||
{
|
||||
if (result == S_OK)
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
|
||||
{
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// MainAr.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#include "Windows/ErrorMsg.h"
|
||||
|
||||
#include "Common/StdOutStream.h"
|
||||
#include "Common/NewHandler.h"
|
||||
#include "Common/MyException.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../Common/ExitCode.h"
|
||||
#include "../Common/ArchiveCommandLine.h"
|
||||
#include "ExtractCallbackConsole.h"
|
||||
#include "NSISBreak.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
#endif
|
||||
#if !defined(_UNICODE) || !defined(_WIN64)
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void DoInitialize()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _UNICODE
|
||||
#ifndef _WIN64
|
||||
if (!IsItWindowsNT())
|
||||
{
|
||||
//(*g_StdStream) << "This program requires Windows NT/2000/2003/2008/XP/Vista";
|
||||
// return NExitCode::kFatalError;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
extern int DoExtractArchive(UString archive, UString targetDir, bool overwrite, bool extractPathes, ExtractProgressHandler epc, const UStringVector& skipPatterns);
|
||||
extern int DoExtractArchiveWithFile(UString archive, UString targetDir, bool overwrite, bool extractPathes, ExtractProgressWithFileHandler epc, const UStringVector& skipPatterns);
|
||||
|
||||
int DoExtract(LPTSTR archive, LPTSTR dir, bool overwrite, bool expath, ExtractProgressHandler epc, const UStringVector& skipPatterns)
|
||||
{
|
||||
if (!archive || !dir) return -1;
|
||||
int res = 0;
|
||||
try
|
||||
{
|
||||
#ifdef UNICODE
|
||||
UString uarchive(archive);
|
||||
UString udir(dir);
|
||||
#else
|
||||
UString uarchive = MultiByteToUnicodeString(AString(archive));
|
||||
UString udir = MultiByteToUnicodeString(AString(dir));
|
||||
#endif
|
||||
res = DoExtractArchive(uarchive, udir, overwrite, expath, epc, skipPatterns);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int DoExtractWithFile(LPTSTR archive, LPTSTR dir, bool overwrite, bool expath, ExtractProgressWithFileHandler epc, const UStringVector& skipPatterns)
|
||||
{
|
||||
if (!archive || !dir) return -1;
|
||||
int res = 0;
|
||||
try
|
||||
{
|
||||
#ifdef UNICODE
|
||||
UString uarchive(archive);
|
||||
UString udir(dir);
|
||||
#else
|
||||
UString uarchive = MultiByteToUnicodeString(AString(archive));
|
||||
UString udir = MultiByteToUnicodeString(AString(dir));
|
||||
#endif
|
||||
res = DoExtractArchiveWithFile(uarchive, udir, overwrite, expath, epc, skipPatterns);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// ConsoleClose.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "NSISBreak.h"
|
||||
|
||||
static int g_BreakCounter = 0;
|
||||
|
||||
namespace NNSISBreak {
|
||||
|
||||
void SendBreakSignal()
|
||||
{
|
||||
g_BreakCounter++;
|
||||
}
|
||||
|
||||
bool TestBreakSignal()
|
||||
{
|
||||
/*
|
||||
if (g_BreakCounter > 0)
|
||||
return true;
|
||||
*/
|
||||
return (g_BreakCounter > 0);
|
||||
}
|
||||
|
||||
void CheckCtrlBreak()
|
||||
{
|
||||
if (TestBreakSignal())
|
||||
throw CCtrlBreakException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef __NSISBREAKUTILS_H
|
||||
#define __NSISBREAKUTILS_H
|
||||
|
||||
namespace NNSISBreak {
|
||||
|
||||
bool TestBreakSignal();
|
||||
void SendBreakSignal();
|
||||
|
||||
class CCtrlBreakException
|
||||
{};
|
||||
|
||||
void CheckCtrlBreak();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "../../Bundles/Nsis7z/pluginapi.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
// UserInputUtils.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/StdInStream.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "UserInputUtils2.h"
|
||||
|
||||
static const char kYes = 'Y';
|
||||
static const char kNo = 'N';
|
||||
static const char kYesAll = 'A';
|
||||
static const char kNoAll = 'S';
|
||||
static const char kAutoRename = 'U';
|
||||
static const char kQuit = 'Q';
|
||||
|
||||
static const char *kFirstQuestionMessage = "?\n";
|
||||
static const char *kHelpQuestionMessage =
|
||||
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? ";
|
||||
|
||||
// return true if pressed Quite;
|
||||
// in: anAll
|
||||
// out: anAll, anYes;
|
||||
|
||||
NUserAnswerMode::EEnum ScanUserYesNoAllQuit2(CStdOutStream *outStream)
|
||||
{
|
||||
(*outStream) << kFirstQuestionMessage;
|
||||
for(;;)
|
||||
{
|
||||
(*outStream) << kHelpQuestionMessage;
|
||||
AString scannedString;
|
||||
g_StdIn.ScanAStringUntilNewLine(scannedString);
|
||||
scannedString.Trim();
|
||||
if(!scannedString.IsEmpty())
|
||||
switch(::MyCharUpper(scannedString[0]))
|
||||
{
|
||||
case kYes:
|
||||
return NUserAnswerMode::kYes;
|
||||
case kNo:
|
||||
return NUserAnswerMode::kNo;
|
||||
case kYesAll:
|
||||
return NUserAnswerMode::kYesAll;
|
||||
case kNoAll:
|
||||
return NUserAnswerMode::kNoAll;
|
||||
case kAutoRename:
|
||||
return NUserAnswerMode::kAutoRename;
|
||||
case kQuit:
|
||||
return NUserAnswerMode::kQuit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UString GetPassword(CStdOutStream *outStream)
|
||||
{
|
||||
(*outStream) << "\nEnter password:";
|
||||
outStream->Flush();
|
||||
AString oemPassword;
|
||||
g_StdIn.ScanAStringUntilNewLine(oemPassword);
|
||||
return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// UserInputUtils.h
|
||||
|
||||
#ifndef __USERINPUTUTILS_H
|
||||
#define __USERINPUTUTILS_H
|
||||
|
||||
#include "Common/StdOutStream.h"
|
||||
|
||||
namespace NUserAnswerMode {
|
||||
|
||||
enum EEnum
|
||||
{
|
||||
kYes,
|
||||
kNo,
|
||||
kYesAll,
|
||||
kNoAll,
|
||||
kAutoRename,
|
||||
kQuit
|
||||
};
|
||||
}
|
||||
|
||||
NUserAnswerMode::EEnum ScanUserYesNoAllQuit2(CStdOutStream *outStream);
|
||||
UString GetPassword(CStdOutStream *outStream);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
../../../../25.01/CPP/7zip/UI/makefile
|
||||
Reference in New Issue
Block a user