Files
nsis-plugin-ns7zip/versions/26.01-bundle/CPP/7zip/UI/NSIS/MainAr.cpp
T
Simone e125ea5f9c feat(26.01): add bundle wrapper directory with NSIS sources and vendor symlinks
7-Zip 26.01 (ip7z/7zip) never shipped NSIS plugin sources, so they live in
a separate bundle directory (versions/26.01-bundle/) that mirrors the layout
expected by the shared overlay makefile and by MSBuild.

Bundle contents:
- CPP/7zip/Bundles/Nsis7z/: NSIS plugin wrapper sources (nsis7z.cpp,
  pluginapi.cpp, api.h, resource.rc, StdAfx.h, …) and the Windows build
  project file (Nsis7z_vs2026.vcxproj, adapted from versions/26.00/).
  The vcxproj references the vendor submodule tree via relative paths
  (../../../../../26.01/…), keeping the submodule pristine.
- CPP/7zip/UI/NSIS/: NSIS UI adapter sources (Main.cpp, MainAr.cpp,
  NSISBreak.cpp, ExtractCallbackConsole.cpp, UserInputUtils2.cpp and
  corresponding headers), copied from versions/26.00/.
- CPP/7zip/LzmaDec_gcc.mak: forwarding stub; GNU make resolves relative
  `include` paths against the CWD, so when make runs from Bundles/Nsis7z
  the upstream Arc_gcc.mak's `include ../../LzmaDec_gcc.mak` lands here.
  The stub re-includes the real file via $(VENDOR_7ZIP).
- Symlinks (C, Asm, CPP/7zip/*, CPP/Common, CPP/Windows, …) pointing into
  the versions/26.01 submodule.  These are required because the vendor
  makefile uses CWD-relative source paths (../../../../C/…, ../../Common/…).
  tools/linux/setup_26_01_bundle_symlinks.py recreates them if needed.
2026-05-03 01:19:44 +02:00

110 lines
2.5 KiB
C++

// 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;
}