Add NSIS plugin support and extraction functionality
- Implemented plugin API in `pluginapi.cpp` and `pluginapi.h` for NSIS integration. - Added resource files `resource.h` and `resource.rc` for versioning and resource management. - Created `ExtractCallbackConsole` class to handle extraction progress and user input. - Developed main extraction logic in `Main.cpp` and `MainAr.cpp` for handling archives. - Introduced user input utilities in `UserInputUtils2.cpp` and `UserInputUtils2.h` for password handling and user prompts. - Added break signal handling in `NSISBreak.cpp` and `NSISBreak.h` for graceful interruption of extraction processes. - Included standard header `StdAfx.h` for precompiled headers and common includes.
This commit is contained in:
@@ -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 "7zip/UI/Common/ExitCode.h"
|
||||
#include "7zip/UI/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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user