Files
LisherSong--ps5-web-file-ma…/third_party/unrar7/rar.cpp
T
Songlx516 c68c0def35 vendor(unrar): add unrar 7.20.1 (RARLab source, opello mirror)
New RAR engine for v1.9, replacing dmc_unrar 1.7.0. dmc_unrar only
dispatches RAR5 compression version 5 (switch(file->version) case
0x5000); WinRAR 6.x/7.x writes version 6 -> DMC_UNRAR_FILE_UNSUPPORTED_VERSION
-> user-facing "corrupt archive" on real v6 archives (diagnosed 2026-09-05
from a v6:8M:m0:m3 test file). unrar 7.20.1 natively supports v6,
encrypted and multi-volume RAR.

Vendored into third_party/unrar7/ (new dir) so the tree stays buildable
while src/rar_extract.c still references the dmc facade. Contents are a
verbatim copy of opello/unrar @97e1780 (159 files, v7.20.1) plus two
project files:
  - unrar_c_api.h  (C facade shim: platform types + dll.hpp re-export)
  - VENDORED.md    (source pin, build model, license notes)

Build model verified on host (MinGW g++ 16.2, Windows):
  - all 49 UnRARDll.vcxproj sources compile with
    -std=c++17 -DRARDLL -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
  - links + runs: RARGetDllVersion() = 9 (smoke binary in .build/, ignored)
  - Windows link additionally needs -lpowrprof

License: UnRAR freeware license (not GPL) - free to use for handling RAR
archives; cannot be used to build a RAR-compatible archiver. THIRD_PARTY_NOTICES
update lands with the engine swap commit.

Next (v1.9 work items): engine swap in rar_extract.c, Makefile .cpp rules,
fixtures + host tests, frontend password/multi-volume, then ELF build.
2026-09-05 21:57:15 +08:00

112 lines
2.5 KiB
C++

#include "rar.hpp"
#if !defined(RARDLL)
int main(int argc, char *argv[])
{
#ifdef _UNIX
setlocale(LC_ALL,"");
#endif
InitConsole();
ErrHandler.SetSignalHandlers(true);
#ifdef SFX_MODULE
std::wstring ModuleName;
#ifdef _WIN_ALL
ModuleName=GetModuleFileStr();
#else
CharToWide(argv[0],ModuleName);
#endif
#endif
#ifdef _WIN_ALL
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
// Must be initialized, normal initialization can be skipped in case of
// exception.
POWER_MODE ShutdownOnClose=POWERMODE_KEEP;
#endif
try
{
// Use std::unique_ptr to free Cmd in case of exception.
std::unique_ptr<CommandData> Cmd(new CommandData);
#ifdef SFX_MODULE
Cmd->Command=L"X";
char *Switch=argc>1 ? argv[1]:NULL;
if (Switch!=NULL && Cmd->IsSwitch(Switch[0]))
{
int UpperCmd=etoupper(Switch[1]);
switch(UpperCmd)
{
case 'T':
case 'V':
// Also copy 't' and 'a' modifiers for -v[t,a], if present.
Cmd->Command.clear();
for (char *c=Switch+1;*c!=0;c++)
Cmd->Command+=etoupper(*c);
break;
case '?':
Cmd->OutHelp(RARX_SUCCESS);
break;
}
}
Cmd->AddArcName(ModuleName);
Cmd->ParseDone();
Cmd->AbsoluteLinks=true; // If users runs SFX, he trusts an archive source.
#else // !SFX_MODULE
Cmd->ParseCommandLine(true,argc,argv);
if (!Cmd->ConfigDisabled)
{
Cmd->ReadConfig();
Cmd->ParseEnvVar();
}
Cmd->ParseCommandLine(false,argc,argv);
#endif
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
ShutdownOnClose=Cmd->Shutdown;
if (ShutdownOnClose!=POWERMODE_KEEP)
ShutdownCheckAnother(true);
#endif
uiInit(Cmd->Sound);
InitLogOptions(Cmd->LogName,Cmd->ErrlogCharset);
ErrHandler.SetSilent(Cmd->AllYes || Cmd->MsgStream==MSG_NULL);
Cmd->OutTitle();
Cmd->ProcessCommand();
}
catch (RAR_EXIT ErrCode)
{
ErrHandler.SetErrorCode(ErrCode);
}
catch (std::bad_alloc&)
{
ErrHandler.MemoryErrorMsg();
ErrHandler.SetErrorCode(RARX_MEMORY);
}
catch (...)
{
ErrHandler.SetErrorCode(RARX_FATAL);
}
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
if (ShutdownOnClose!=POWERMODE_KEEP && ErrHandler.IsShutdownEnabled() &&
!ShutdownCheckAnother(false))
Shutdown(ShutdownOnClose);
#endif
ErrHandler.MainExit=true;
CloseLogOptions();
return ErrHandler.GetErrorCode();
}
#endif