Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2014-03-18 18:04:42 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2014-03-19 13:00:00 +0400
commit7d361f58b65264857e2244964914640efb7cfaa4 (patch)
tree40b64163d0b6d92d623df37416dae046ea73d9f6 /src/thirdparty/unrar
parent44c3827e1f29793f00fda52407066ecfa79e5f0c (diff)
Update unrar to v5.1.1.
Diffstat (limited to 'src/thirdparty/unrar')
-rw-r--r--src/thirdparty/unrar/arccmt.cpp8
-rw-r--r--src/thirdparty/unrar/archive.cpp68
-rw-r--r--src/thirdparty/unrar/archive.hpp2
-rw-r--r--src/thirdparty/unrar/arcread.cpp79
-rw-r--r--src/thirdparty/unrar/cmddata.cpp78
-rw-r--r--src/thirdparty/unrar/coder.hpp2
-rw-r--r--src/thirdparty/unrar/compress.hpp67
-rw-r--r--src/thirdparty/unrar/consio.cpp35
-rw-r--r--src/thirdparty/unrar/consio.hpp4
-rw-r--r--src/thirdparty/unrar/crc.cpp2
-rw-r--r--src/thirdparty/unrar/crypt2.cpp8
-rw-r--r--src/thirdparty/unrar/crypt3.cpp14
-rw-r--r--src/thirdparty/unrar/dll.cpp15
-rw-r--r--src/thirdparty/unrar/dll.rc10
-rw-r--r--src/thirdparty/unrar/errhnd.cpp140
-rw-r--r--src/thirdparty/unrar/errhnd.hpp6
-rw-r--r--src/thirdparty/unrar/extract.cpp163
-rw-r--r--src/thirdparty/unrar/extract.hpp23
-rw-r--r--src/thirdparty/unrar/filcreat.cpp95
-rw-r--r--src/thirdparty/unrar/filcreat.hpp2
-rw-r--r--src/thirdparty/unrar/file.cpp75
-rw-r--r--src/thirdparty/unrar/file.hpp32
-rw-r--r--src/thirdparty/unrar/filefn.cpp17
-rw-r--r--src/thirdparty/unrar/find.cpp9
-rw-r--r--src/thirdparty/unrar/hardlinks.cpp4
-rw-r--r--src/thirdparty/unrar/loclang.hpp771
-rw-r--r--src/thirdparty/unrar/log.cpp2
-rw-r--r--src/thirdparty/unrar/model.cpp69
-rw-r--r--src/thirdparty/unrar/model.hpp74
-rw-r--r--src/thirdparty/unrar/options.cpp1
-rw-r--r--src/thirdparty/unrar/options.hpp4
-rw-r--r--src/thirdparty/unrar/os.hpp28
-rw-r--r--src/thirdparty/unrar/pathfn.cpp133
-rw-r--r--src/thirdparty/unrar/pathfn.hpp34
-rw-r--r--src/thirdparty/unrar/rar.cpp5
-rw-r--r--src/thirdparty/unrar/rar.hpp9
-rw-r--r--src/thirdparty/unrar/rardefs.hpp5
-rw-r--r--src/thirdparty/unrar/raros.hpp5
-rw-r--r--src/thirdparty/unrar/rarvm.cpp10
-rw-r--r--src/thirdparty/unrar/rawread.cpp7
-rw-r--r--src/thirdparty/unrar/rawread.hpp49
-rw-r--r--src/thirdparty/unrar/rdwrfn.cpp4
-rw-r--r--src/thirdparty/unrar/rdwrfn.hpp1
-rw-r--r--src/thirdparty/unrar/recvol.cpp2
-rw-r--r--src/thirdparty/unrar/recvol3.cpp98
-rw-r--r--src/thirdparty/unrar/recvol5.cpp54
-rw-r--r--src/thirdparty/unrar/resource.cpp9
-rw-r--r--src/thirdparty/unrar/rijndael.cpp170
-rw-r--r--src/thirdparty/unrar/rijndael.hpp17
-rw-r--r--src/thirdparty/unrar/scantree.cpp11
-rw-r--r--src/thirdparty/unrar/sha1.cpp23
-rw-r--r--src/thirdparty/unrar/sha1.hpp8
-rw-r--r--src/thirdparty/unrar/sha256.cpp2
-rw-r--r--src/thirdparty/unrar/strfn.cpp41
-rw-r--r--src/thirdparty/unrar/strfn.hpp3
-rw-r--r--src/thirdparty/unrar/suballoc.cpp17
-rw-r--r--src/thirdparty/unrar/suballoc.hpp36
-rw-r--r--src/thirdparty/unrar/threadmisc.cpp77
-rw-r--r--src/thirdparty/unrar/threadpool.cpp11
-rw-r--r--src/thirdparty/unrar/threadpool.hpp4
-rw-r--r--src/thirdparty/unrar/timefn.cpp36
-rw-r--r--src/thirdparty/unrar/timefn.hpp6
-rw-r--r--src/thirdparty/unrar/ui.cpp15
-rw-r--r--src/thirdparty/unrar/ui.hpp162
-rw-r--r--src/thirdparty/unrar/uicommon.cpp58
-rw-r--r--src/thirdparty/unrar/uiconsole.cpp366
-rw-r--r--src/thirdparty/unrar/uisilent.cpp63
-rw-r--r--src/thirdparty/unrar/ulinks.cpp4
-rw-r--r--src/thirdparty/unrar/unicode.cpp89
-rw-r--r--src/thirdparty/unrar/unicode.hpp3
-rw-r--r--src/thirdparty/unrar/unpack.cpp14
-rw-r--r--src/thirdparty/unrar/unpack.hpp4
-rw-r--r--src/thirdparty/unrar/unpack50.cpp14
-rw-r--r--src/thirdparty/unrar/unpack50mt.cpp2
-rw-r--r--src/thirdparty/unrar/unrar.vcxproj2
-rw-r--r--src/thirdparty/unrar/unrar.vcxproj.filters6
-rw-r--r--src/thirdparty/unrar/uowners.cpp20
-rw-r--r--src/thirdparty/unrar/version.hpp10
-rw-r--r--src/thirdparty/unrar/volume.cpp31
-rw-r--r--src/thirdparty/unrar/volume.hpp1
-rw-r--r--src/thirdparty/unrar/win32acl.cpp10
-rw-r--r--src/thirdparty/unrar/win32lnk.cpp77
-rw-r--r--src/thirdparty/unrar/win32stm.cpp20
83 files changed, 2162 insertions, 1603 deletions
diff --git a/src/thirdparty/unrar/arccmt.cpp b/src/thirdparty/unrar/arccmt.cpp
index c8e6f0e1c..8789f6015 100644
--- a/src/thirdparty/unrar/arccmt.cpp
+++ b/src/thirdparty/unrar/arccmt.cpp
@@ -28,14 +28,14 @@ bool Archive::GetComment(Array<wchar> *CmtData)
{
// Current (RAR 3.0+) version of archive comment.
Seek(GetStartPos(),SEEK_SET);
- return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData));
+ return SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData);
}
#ifndef SFX_MODULE
// Old style (RAR 2.9) comment header embedded into the main
// archive header.
if (BrokenHeader)
{
- Log(FileName,St(MLogCommHead));
+ uiMsg(UIERROR_CMTBROKEN,FileName);
return false;
}
CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD;
@@ -75,7 +75,7 @@ bool Archive::GetComment(Array<wchar> *CmtData)
if (Format!=RARFMT14 && (DataIO.UnpHash.GetCRC32()&0xffff)!=CommHead.CommCRC)
{
- Log(FileName,St(MLogCommBrk));
+ uiMsg(UIERROR_CMTBROKEN,FileName);
return false;
}
else
@@ -99,7 +99,7 @@ bool Archive::GetComment(Array<wchar> *CmtData)
if (Format!=RARFMT14 && CommHead.CommCRC!=(~CRC32(0xffffffff,&CmtRaw[0],CmtLength)&0xffff))
{
- Log(FileName,St(MLogCommBrk));
+ uiMsg(UIERROR_CMTBROKEN,FileName);
return false;
}
CmtData->Alloc(CmtLength+1);
diff --git a/src/thirdparty/unrar/archive.cpp b/src/thirdparty/unrar/archive.cpp
index ab33b2d01..9e9e72424 100644
--- a/src/thirdparty/unrar/archive.cpp
+++ b/src/thirdparty/unrar/archive.cpp
@@ -68,9 +68,7 @@ void Archive::CheckArc(bool EnableBroken)
// If FailedHeaderDecryption is set, we already reported that archive
// password is incorrect.
if (!FailedHeaderDecryption)
- {
- Log(FileName,St(MBadArc),FileName);
- }
+ uiMsg(UIERROR_BADARCHIVE,FileName);
ErrHandler.Exit(RARX_FATAL);
}
}
@@ -92,9 +90,7 @@ bool Archive::WCheckOpen(const wchar *Name)
return false;
if (!IsArchive(false))
{
-#ifndef SHELL_EXT
- Log(FileName,St(MNotRAR),FileName);
-#endif
+ uiMsg(UIERROR_BADARCHIVE,FileName);
Close();
return false;
}
@@ -133,25 +129,16 @@ bool Archive::IsArchive(bool EnableBroken)
{
Encrypted=false;
BrokenHeader=false; // Might be left from previous volume.
-#ifdef USE_QOPEN
- QOpen.Unload();
-#endif
-
- // Important if we reuse Archive object and it has virtual QOpen
- // file position not matching real. For example, for 'l -v volname'.
- Seek(0,SEEK_SET);
#ifndef SFX_MODULE
if (IsDevice())
{
-#ifndef SHELL_EXT
- Log(FileName,St(MInvalidName),FileName);
-#endif
+ uiMsg(UIERROR_INVALIDNAME,FileName,FileName);
return false;
}
#endif
if (Read(MarkHead.Mark,SIZEOF_MARKHEAD3)!=SIZEOF_MARKHEAD3)
- return(false);
+ return false;
SFXSize=0;
RARFORMAT Type;
@@ -159,7 +146,7 @@ bool Archive::IsArchive(bool EnableBroken)
{
Format=Type;
if (Format==RARFMT14)
- Seek(0,SEEK_SET);
+ Seek(Tell()-SIZEOF_MARKHEAD3,SEEK_SET);
}
else
{
@@ -187,9 +174,7 @@ bool Archive::IsArchive(bool EnableBroken)
}
if (Format==RARFMT_FUTURE)
{
-#if !defined(SHELL_EXT) && !defined(SFX_MODULE)
- Log(FileName,St(MNewRarFormat));
-#endif
+ uiMsg(UIERROR_NEWRARFORMAT,FileName);
return false;
}
if (Format==RARFMT50) // RAR 5.0 signature is by one byte longer.
@@ -229,31 +214,13 @@ bool Archive::IsArchive(bool EnableBroken)
return false;
SeekToNext();
- if (BrokenHeader)
+ if (BrokenHeader) // Main archive header is corrupt.
{
-#ifndef SHELL_EXT
- Log(FileName,St(MMainHeaderBroken));
-#endif
+ uiMsg(UIERROR_MHEADERBROKEN,FileName);
if (!EnableBroken)
return false;
}
-/*
- if (MainHead.EncryptVer>VER_UNPACK)
- {
-#ifdef RARDLL
- Cmd->DllError=ERAR_UNKNOWN_FORMAT;
-#else
- ErrHandler.SetErrorCode(RARX_WARNING);
- #if !defined(SILENT) && !defined(SFX_MODULE)
- Log(FileName,St(MUnknownMeth),FileName);
- Log(FileName,St(MVerRequired),MainHead.EncryptVer/10,MainHead.EncryptVer%10);
- #endif
-#endif
- return(false);
- }
-*/
-
MainComment=MainHead.CommentInHeader;
// If we process non-encrypted archive or can request a password,
@@ -274,10 +241,11 @@ bool Archive::IsArchive(bool EnableBroken)
if (HeaderType==HEAD_SERVICE)
FirstVolume=Volume && !SubHead.SplitBefore;
else
- {
- FirstVolume=Volume && HeaderType==HEAD_FILE && !FileHead.SplitBefore;
- break;
- }
+ if (HeaderType==HEAD_FILE)
+ {
+ FirstVolume=Volume && !FileHead.SplitBefore;
+ break;
+ }
SeekToNext();
}
CurBlockPos=SaveCurBlockPos;
@@ -320,6 +288,16 @@ uint Archive::FullHeaderSize(size_t Size)
#ifdef USE_QOPEN
+bool Archive::Open(const wchar *Name,uint Mode)
+{
+ // Important if we reuse Archive object and it has virtual QOpen
+ // file position not matching real. For example, for 'l -v volname'.
+ QOpen.Unload();
+
+ return File::Open(Name,Mode);
+}
+
+
int Archive::Read(void *Data,size_t Size)
{
size_t Result;
diff --git a/src/thirdparty/unrar/archive.hpp b/src/thirdparty/unrar/archive.hpp
index 95645edc2..1d8444bfb 100644
--- a/src/thirdparty/unrar/archive.hpp
+++ b/src/thirdparty/unrar/archive.hpp
@@ -86,10 +86,10 @@ class Archive:public File
const wchar *Name,uint Flags);
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
HEADER_TYPE GetHeaderType() {return(CurHeaderType);};
- void WriteCommentData(byte *Data,size_t DataSize,bool FileComment);
RAROptions* GetRAROptions() {return(Cmd);}
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
#ifdef USE_QOPEN
+ bool Open(const wchar *Name,uint Mode=FMF_READ);
int Read(void *Data,size_t Size);
void Seek(int64 Offset,int Method);
int64 Tell();
diff --git a/src/thirdparty/unrar/arcread.cpp b/src/thirdparty/unrar/arcread.cpp
index f9661968e..8395d460d 100644
--- a/src/thirdparty/unrar/arcread.cpp
+++ b/src/thirdparty/unrar/arcread.cpp
@@ -88,12 +88,9 @@ void Archive::UnexpEndArcMsg()
// If block positions are equal to file size, this is not an error.
// It can happen when we reached the end of older RAR 1.5 archive,
// which did not have the end of archive block.
- if (CurBlockPos>ArcSize || NextBlockPos>ArcSize ||
- CurBlockPos!=ArcSize && NextBlockPos!=ArcSize && Format==RARFMT50)
+ if (CurBlockPos!=ArcSize || NextBlockPos!=ArcSize)
{
-#ifndef SHELL_EXT
- Log(FileName,St(MLogUnexpEOF));
-#endif
+ uiMsg(UIERROR_UNEXPEOF,FileName);
ErrHandler.SetErrorCode(RARX_WARNING);
}
}
@@ -101,9 +98,7 @@ void Archive::UnexpEndArcMsg()
void Archive::BrokenHeaderMsg()
{
-#ifndef SHELL_EXT
- Log(FileName,St(MHeaderBroken));
-#endif
+ uiMsg(UIERROR_HEADERBROKEN,FileName);
BrokenHeader=true;
ErrHandler.SetErrorCode(RARX_CRC);
}
@@ -111,9 +106,7 @@ void Archive::BrokenHeaderMsg()
void Archive::UnkEncVerMsg(const wchar *Name)
{
-#ifndef SHELL_EXT
- Log(FileName,St(MUnkEncMethod),Name);
-#endif
+ uiMsg(UIERROR_UNKNOWNENCMETHOD,FileName,Name);
ErrHandler.SetErrorCode(RARX_WARNING);
}
@@ -317,15 +310,10 @@ size_t Archive::ReadHeader15()
{
EncodeFileName NameCoder;
size_t Length=strlen(FileName);
- if (Length==NameSize)
- UtfToWide(FileName,hd->FileName,ASIZE(hd->FileName)-1);
- else
- {
- Length++;
- NameCoder.Decode(FileName,(byte *)FileName+Length,
- NameSize-Length,hd->FileName,
- ASIZE(hd->FileName));
- }
+ Length++;
+ NameCoder.Decode(FileName,(byte *)FileName+Length,
+ NameSize-Length,hd->FileName,
+ ASIZE(hd->FileName));
}
else
*hd->FileName=0;
@@ -420,11 +408,7 @@ size_t Archive::ReadHeader15()
// to have anything sensible in file name field, so it is useless
// to display the file name.
if (!Decrypt)
- {
-#ifndef SHELL_EXT
- Log(Archive::FileName,St(MLogFileHead),hd->FileName);
-#endif
- }
+ uiMsg(UIERROR_FHEADERBROKEN,Archive::FileName,hd->FileName);
}
}
break;
@@ -552,9 +536,7 @@ size_t Archive::ReadHeader15()
if (Decrypt)
{
-#ifndef SILENT
- Log(FileName,St(MEncrBadCRC),FileName);
-#endif
+ uiMsg(UIERROR_CHECKSUMENC,FileName,FileName);
FailedHeaderDecryption=true;
return 0;
}
@@ -596,7 +578,7 @@ size_t Archive::ReadHeader50()
// Verify password validity.
if (CryptHead.UsePswCheck && memcmp(PswCheck,CryptHead.PswCheck,SIZE_PSWCHECK)!=0)
{
- Log(FileName,St(MWrongPassword));
+ uiMsg(UIERROR_BADPSW,FileName);
FailedHeaderDecryption=true;
ErrHandler.SetErrorCode(RARX_BADPWD);
return 0;
@@ -609,7 +591,7 @@ size_t Archive::ReadHeader50()
// Header size must not occupy more than 3 variable length integer bytes
// resulting in 2 MB maximum header size, so here we read 4 byte CRC32
// followed by 3 bytes or less of header size.
- const size_t FirstReadSize=7;
+ const size_t FirstReadSize=7; // Smallest possible block size.
if (Raw.Read(FirstReadSize)<FirstReadSize)
{
UnexpEndArcMsg();
@@ -664,9 +646,7 @@ size_t Archive::ReadHeader50()
if (Decrypt)
{
-#ifndef SILENT
- Log(FileName,St(MEncrBadCRC),FileName);
-#endif
+ uiMsg(UIERROR_CHECKSUMENC,FileName,FileName);
FailedHeaderDecryption=true;
return 0;
}
@@ -850,13 +830,8 @@ size_t Archive::ReadHeader50()
MainComment=true;
- if (BadCRC)
- {
- // Add the file name to broken header message displayed above.
-#ifndef SHELL_EXT
- Log(Archive::FileName,St(MLogFileHead),hd->FileName);
-#endif
- }
+ if (BadCRC) // Add the file name to broken header message displayed above.
+ uiMsg(UIERROR_FHEADERBROKEN,Archive::FileName,hd->FileName);
}
break;
case HEAD_ENDARC:
@@ -911,9 +886,10 @@ void Archive::RequestArcPassword()
ErrHandler.Exit(RARX_USERBREAK);
}
#else
- if (!GetPassword(PASSWORD_ARCHIVE,FileName,&Cmd->Password))
+ if (!uiGetPassword(UIPASSWORD_ARCHIVE,FileName,&Cmd->Password))
{
Close();
+ uiMsg(UIERROR_INCERRCOUNT);
ErrHandler.Exit(RARX_USERBREAK);
}
#endif
@@ -1180,6 +1156,7 @@ size_t Archive::ReadHeader14()
char FileName[NM];
Raw.GetB((byte *)FileName,Min(NameSize,ASIZE(FileName)));
FileName[NameSize]=0;
+ IntToExt(FileName,FileName,ASIZE(FileName));
CharToWide(FileName,FileHead.FileName,ASIZE(FileHead.FileName));
ConvertNameCase(FileHead.FileName);
@@ -1220,6 +1197,10 @@ void Archive::ConvertAttributes()
// when creating a file or directory. The typical default value
// for the process umask is S_IWGRP | S_IWOTH (octal 022),
// resulting in 0644 mode for new files.
+ // Normally umask is applied automatically when creating a file,
+ // but we set attributes with chmod later, so we need to calculate
+ // resulting attributes here. We do it only for non-Unix archives.
+ // We restore native Unix attributes as is, because it can be backup.
static mode_t mask = (mode_t) -1;
if (mask == (mode_t) -1)
@@ -1333,17 +1314,13 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
{
if (BrokenHeader)
{
-#ifndef SHELL_EXT
- Log(FileName,St(MSubHeadCorrupt));
-#endif
+ uiMsg(UIERROR_SUBHEADERBROKEN,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return false;
}
if (SubHead.Method>5 || SubHead.UnpVer>(Format==RARFMT50 ? VER_UNPACK5:VER_UNPACK))
{
-#ifndef SHELL_EXT
- Log(FileName,St(MSubHeadUnknown));
-#endif
+ uiMsg(UIERROR_SUBHEADERUNKNOWN,FileName);
return false;
}
@@ -1359,9 +1336,7 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
if (SubHead.UnpSize>0x1000000)
{
// So huge allocation must never happen in valid archives.
-#ifndef SHELL_EXT
- Log(FileName,St(MSubHeadUnknown));
-#endif
+ uiMsg(UIERROR_SUBHEADERUNKNOWN,FileName);
return false;
}
UnpData->Alloc((size_t)SubHead.UnpSize);
@@ -1388,9 +1363,7 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
if (!SubDataIO.UnpHash.Cmp(&SubHead.FileHash,SubHead.UseHashKey ? SubHead.HashKey:NULL))
{
-#ifndef SHELL_EXT
- Log(FileName,St(MSubHeadDataCRC),SubHead.FileName);
-#endif
+ uiMsg(UIERROR_SUBHEADERDATABROKEN,FileName,SubHead.FileName);
ErrHandler.SetErrorCode(RARX_CRC);
if (UnpData!=NULL)
UnpData->Reset();
diff --git a/src/thirdparty/unrar/cmddata.cpp b/src/thirdparty/unrar/cmddata.cpp
index be3a2bdd0..f2374f146 100644
--- a/src/thirdparty/unrar/cmddata.cpp
+++ b/src/thirdparty/unrar/cmddata.cpp
@@ -1,6 +1,5 @@
#include "rar.hpp"
-
CommandData::CommandData()
{
Init();
@@ -45,7 +44,7 @@ static const wchar *AllocCmdParam(const wchar *CmdLine,wchar **Par)
}
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
{
#ifdef CUSTOM_CMDLINE_PARSER
@@ -90,7 +89,7 @@ void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
#endif
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ParseArg(wchar *Arg)
{
if (IsSwitch(*Arg) && !NoMoreSwitches)
@@ -182,7 +181,7 @@ void CommandData::ParseDone()
}
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ParseEnvVar()
{
char *EnvStr=getenv("RAR");
@@ -197,7 +196,7 @@ void CommandData::ParseEnvVar()
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
// Preprocess those parameters, which must be processed before the rest of
// command line. Return 'false' to stop further processing.
bool CommandData::PreprocessSwitch(const wchar *Switch)
@@ -235,7 +234,7 @@ bool CommandData::PreprocessSwitch(const wchar *Switch)
#endif
-#if !defined(GUI) && !defined(SFX_MODULE)
+#if !defined(GUI) && !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ReadConfig()
{
StringList List;
@@ -254,7 +253,7 @@ void CommandData::ReadConfig()
#endif
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ProcessSwitchesString(const wchar *Str)
{
wchar *Par;
@@ -268,7 +267,7 @@ void CommandData::ProcessSwitchesString(const wchar *Str)
#endif
-#if !defined(SFX_MODULE)
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::ProcessSwitch(const wchar *Switch)
{
@@ -366,17 +365,14 @@ void CommandData::ProcessSwitch(const wchar *Switch)
break;
}
break;
- case 'E':
- ProcessEA=false;
- break;
default:
if (Switch[1]=='+')
{
- InclFileAttr=GetExclAttr(Switch+2);
+ InclFileAttr|=GetExclAttr(Switch+2);
InclAttrSet=true;
}
else
- ExclFileAttr=GetExclAttr(Switch+1);
+ ExclFileAttr|=GetExclAttr(Switch+1);
break;
}
break;
@@ -399,7 +395,7 @@ void CommandData::ProcessSwitch(const wchar *Switch)
else
if (!Password.IsSet())
{
- GetPassword(PASSWORD_GLOBAL,NULL,&Password);
+ uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password);
eprintf(L"\n");
}
break;
@@ -534,7 +530,7 @@ void CommandData::ProcessSwitch(const wchar *Switch)
Names++;
wchar Mask[NM];
if (wcspbrk(Names,L"*?.")==NULL)
- swprintf(Mask,ASIZE(Mask),L"*.%s",Names);
+ swprintf(Mask,ASIZE(Mask),L"*.%ls",Names);
else
wcsncpyz(Mask,Names,ASIZE(Mask));
StoreArgs.AddString(Mask);
@@ -630,7 +626,7 @@ void CommandData::ProcessSwitch(const wchar *Switch)
case 'P':
if (Switch[1]==0)
{
- GetPassword(PASSWORD_GLOBAL,NULL,&Password);
+ uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password);
eprintf(L"\n");
}
else
@@ -885,7 +881,7 @@ void CommandData::ProcessSwitch(const wchar *Switch)
#endif
-#ifndef SFX_MODULE
+#if !defined(SFX_MODULE) && !defined(_ANDROID)
void CommandData::BadSwitch(const wchar *Switch)
{
mprintf(St(MUnknownOption),Switch);
@@ -931,7 +927,7 @@ inline bool CmpMSGID(MSGID i1,MSGID i2)
// If MSGID is const char*, we cannot compare pointers only.
// Pointers to different instances of same string can differ,
// so we need to compare complete strings.
- return strcmp(i1,i2)==0;
+ return wcscmp(i1,i2)==0;
#endif
}
@@ -952,9 +948,10 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
MCHelpSwO,MCHelpSwOC,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
- MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,
- MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,
- MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY
+ MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSL,MCHelpSwSM,
+ MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,
+ MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,
+ MCHelpSwY
#else
#endif
};
@@ -995,15 +992,6 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
if (CmpMSGID(Help[I],MCHelpSwMT))
continue;
#endif
- if (CmpMSGID(Help[I],MCHelpSwEE))
- {
-#if defined(_EMX) && !defined(_DJGPP)
- if (_osmode != OS2_MODE)
- continue;
-#else
- continue;
-#endif
- }
#endif
mprintf(St(Help[I]));
}
@@ -1228,7 +1216,7 @@ void CommandData::ProcessCommand()
case 'I':
{
CmdExtract Extract(this);
- Extract.DoExtract(this);
+ Extract.DoExtract();
}
break;
#ifndef SILENT
@@ -1334,37 +1322,23 @@ void CommandData::ReportWrongSwitches(RARFORMAT Format)
if (Format==RARFMT15)
{
if (HashType!=HASH_CRC32)
- {
- mprintf(St(MIncompatSwitch),L"-ht",4);
- }
+ uiMsg(UIERROR_INCOMPATSWITCH,L"-ht",4);
#ifdef _WIN_ALL
if (SaveSymLinks)
- {
- mprintf(St(MIncompatSwitch),L"-ol",4);
- }
+ uiMsg(UIERROR_INCOMPATSWITCH,L"-ol",4);
#endif
if (SaveHardLinks)
- {
- mprintf(St(MIncompatSwitch),L"-oh",4);
- }
+ uiMsg(UIERROR_INCOMPATSWITCH,L"-oh",4);
#ifdef _WIN_ALL
+ // Do not report a wrong dictionary size here, because we are not sure
+ // yet about archive format. We can switch to RAR5 mode later
+ // if we update RAR5 archive.
#endif
if (QOpenMode!=QOPEN_AUTO)
- {
- mprintf(St(MIncompatSwitch),L"-qo",4);
- }
-/*
- // We use 64 MB for both formats and reduce it for RAR 4.x later.
- if (WinSize>0x400000)
- {
- wchar SwMD[10];
- swprintf(SwMD,ASIZE(SwMD),L"-md%dm",WinSize/0x100000);
- mprintf(St(MIncompatSwitch),SwMD,4);
- }
-*/
+ uiMsg(UIERROR_INCOMPATSWITCH,L"-qo",4);
}
if (Format==RARFMT50)
{
diff --git a/src/thirdparty/unrar/coder.hpp b/src/thirdparty/unrar/coder.hpp
index 0c8156c44..7b36ff218 100644
--- a/src/thirdparty/unrar/coder.hpp
+++ b/src/thirdparty/unrar/coder.hpp
@@ -2,8 +2,6 @@
* Contents: 'Carryless rangecoder' by Dmitry Subbotin *
****************************************************************************/
-const uint TOP=1 << 24, BOT=1 << 15;
-
class RangeCoder
{
diff --git a/src/thirdparty/unrar/compress.hpp b/src/thirdparty/unrar/compress.hpp
index fbeaa2d2d..8e4f1ed34 100644
--- a/src/thirdparty/unrar/compress.hpp
+++ b/src/thirdparty/unrar/compress.hpp
@@ -1,36 +1,43 @@
#ifndef _RAR_COMPRESS_
#define _RAR_COMPRESS_
-#define MAX_LZ_MATCH 0x1001
-#define MAX3_LZ_MATCH 0x101 // Maximum match length for RAR v3.
-
-#define LOW_DIST_REP_COUNT 16
-
-#define NC 306 /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define DC 64
-#define LDC 16
-#define RC 44
-#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
-#define BC 20
-
-#define NC30 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define DC30 60
-#define LDC30 17
-#define RC30 28
-#define BC30 20
-#define HUFF_TABLE_SIZE30 (NC30+DC30+RC30+LDC30)
-
-#define NC20 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define DC20 48
-#define RC20 28
-#define BC20 19
-#define MC20 257
-
-// Largest alphabet size among all values listed above.
-#define LARGEST_TABLE_SIZE 306
-
-enum {CODE_HUFFMAN,CODE_LZ,CODE_REPEATLZ,CODE_CACHELZ,
- CODE_STARTFILE,CODE_ENDFILE,CODE_FILTER,CODE_FILTERDATA};
+// Combine pack and unpack constants to class to avoid polluting global
+// namespace with numerous short names.
+class PackDef
+{
+ public:
+ static const uint MAX_LZ_MATCH = 0x1001;
+ static const uint MAX3_LZ_MATCH = 0x101; // Maximum match length for RAR v3.
+ static const uint LOW_DIST_REP_COUNT = 16;
+
+ static const uint NC = 306; /* alphabet = {0, 1, 2, ..., NC - 1} */
+ static const uint DC = 64;
+ static const uint LDC = 16;
+ static const uint RC = 44;
+ static const uint HUFF_TABLE_SIZE = NC + DC + RC + LDC;
+ static const uint BC = 20;
+
+ static const uint NC30 = 299; /* alphabet = {0, 1, 2, ..., NC - 1} */
+ static const uint DC30 = 60;
+ static const uint LDC30 = 17;
+ static const uint RC30 = 28;
+ static const uint BC30 = 20;
+ static const uint HUFF_TABLE_SIZE30 = NC30 + DC30 + RC30 + LDC30;
+
+ static const uint NC20 = 298; /* alphabet = {0, 1, 2, ..., NC - 1} */
+ static const uint DC20 = 48;
+ static const uint RC20 = 28;
+ static const uint BC20 = 19;
+ static const uint MC20 = 257;
+
+ // Largest alphabet size among all values listed above.
+ static const uint LARGEST_TABLE_SIZE = 306;
+
+ enum {
+ CODE_HUFFMAN, CODE_LZ, CODE_REPEATLZ, CODE_CACHELZ, CODE_STARTFILE,
+ CODE_ENDFILE, CODE_FILTER, CODE_FILTERDATA
+ };
+};
enum FilterType {
diff --git a/src/thirdparty/unrar/consio.cpp b/src/thirdparty/unrar/consio.cpp
index 46079d2ef..f372db398 100644
--- a/src/thirdparty/unrar/consio.cpp
+++ b/src/thirdparty/unrar/consio.cpp
@@ -2,7 +2,6 @@
#include "log.cpp"
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
-static bool Sound=false;
const int MaxMsgSize=2*NM+2048;
#ifdef _WIN_ALL
@@ -47,10 +46,9 @@ void InitConsole()
}
-void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound)
+void InitConsoleOptions(MESSAGE_TYPE MsgStream)
{
::MsgStream=MsgStream;
- ::Sound=Sound;
}
@@ -125,25 +123,6 @@ void eprintf(const wchar *fmt,...)
#ifndef SILENT
-void Alarm()
-{
- if (Sound)
- {
- static clock_t LastTime=clock();
- if ((clock()-LastTime)/CLOCKS_PER_SEC>5)
- {
-#ifdef _WIN_ALL
- MessageBeep(-1);
-#else
- putwchar('\007');
-#endif
- }
- }
-}
-#endif
-
-
-#ifndef SILENT
static void GetPasswordText(wchar *Str,uint MaxLength)
{
if (MaxLength==0)
@@ -181,22 +160,22 @@ static void GetPasswordText(wchar *Str,uint MaxLength)
#ifndef SILENT
-bool GetConsolePassword(PASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
+bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
{
- Alarm();
+ uiAlarm(UIALARM_QUESTION);
while (true)
{
- if (Type==PASSWORD_GLOBAL)
+ if (Type==UIPASSWORD_GLOBAL)
eprintf(L"\n%s: ",St(MAskPsw));
else
eprintf(St(MAskPswFor),FileName);
wchar PlainPsw[MAXPASSWORD];
GetPasswordText(PlainPsw,ASIZE(PlainPsw));
- if (*PlainPsw==0 && Type==PASSWORD_GLOBAL)
+ if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL)
return false;
- if (Type==PASSWORD_GLOBAL)
+ if (Type==UIPASSWORD_GLOBAL)
{
eprintf(St(MReAskPsw));
wchar CmpStr[MAXPASSWORD];
@@ -266,7 +245,7 @@ bool getwstr(wchar *str,size_t n)
#ifndef SILENT
int Ask(const wchar *AskStr)
{
- Alarm();
+ uiAlarm(UIALARM_QUESTION);
const int MaxItems=10;
wchar Item[MaxItems][40];
diff --git a/src/thirdparty/unrar/consio.hpp b/src/thirdparty/unrar/consio.hpp
index 225755e77..5c9e67da1 100644
--- a/src/thirdparty/unrar/consio.hpp
+++ b/src/thirdparty/unrar/consio.hpp
@@ -2,11 +2,11 @@
#define _RAR_CONSIO_
void InitConsole();
-void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound);
+void InitConsoleOptions(MESSAGE_TYPE MsgStream);
void OutComment(const wchar *Comment,size_t Size);
#ifndef SILENT
-bool GetConsolePassword(PASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
+bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
#endif
#ifdef SILENT
diff --git a/src/thirdparty/unrar/crc.cpp b/src/thirdparty/unrar/crc.cpp
index ddd6dc8de..d593281e7 100644
--- a/src/thirdparty/unrar/crc.cpp
+++ b/src/thirdparty/unrar/crc.cpp
@@ -56,7 +56,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size)
byte *Data=(byte *)Addr;
// Align Data to 8 for better performance.
- for (;Size>0 && ((long)Data & 7);Size--,Data++)
+ for (;Size>0 && ((size_t)Data & 7);Size--,Data++)
StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8);
for (;Size>=8;Size-=8,Data+=8)
diff --git a/src/thirdparty/unrar/crypt2.cpp b/src/thirdparty/unrar/crypt2.cpp
index 08c7ecf3a..01d72f862 100644
--- a/src/thirdparty/unrar/crypt2.cpp
+++ b/src/thirdparty/unrar/crypt2.cpp
@@ -62,7 +62,7 @@ void CryptData::SetKey20(const char *Password)
void CryptData::EncryptBlock20(byte *Buf)
{
uint A,B,C,D,T,TA,TB;
-#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_MISALIGNED)
A=((uint)Buf[0]|((uint)Buf[1]<<8)|((uint)Buf[2]<<16)|((uint)Buf[3]<<24))^Key20[0];
B=((uint)Buf[4]|((uint)Buf[5]<<8)|((uint)Buf[6]<<16)|((uint)Buf[7]<<24))^Key20[1];
C=((uint)Buf[8]|((uint)Buf[9]<<8)|((uint)Buf[10]<<16)|((uint)Buf[11]<<24))^Key20[2];
@@ -85,7 +85,7 @@ void CryptData::EncryptBlock20(byte *Buf)
C=TA;
D=TB;
}
-#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_MISALIGNED)
C^=Key20[0];
Buf[0]=(byte)C;
Buf[1]=(byte)(C>>8);
@@ -120,7 +120,7 @@ void CryptData::DecryptBlock20(byte *Buf)
{
byte InBuf[16];
uint A,B,C,D,T,TA,TB;
-#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_MISALIGNED)
A=((uint)Buf[0]|((uint)Buf[1]<<8)|((uint)Buf[2]<<16)|((uint)Buf[3]<<24))^Key20[0];
B=((uint)Buf[4]|((uint)Buf[5]<<8)|((uint)Buf[6]<<16)|((uint)Buf[7]<<24))^Key20[1];
C=((uint)Buf[8]|((uint)Buf[9]<<8)|((uint)Buf[10]<<16)|((uint)Buf[11]<<24))^Key20[2];
@@ -144,7 +144,7 @@ void CryptData::DecryptBlock20(byte *Buf)
C=TA;
D=TB;
}
-#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_MISALIGNED)
C^=Key20[0];
Buf[0]=(byte)C;
Buf[1]=(byte)(C>>8);
diff --git a/src/thirdparty/unrar/crypt3.cpp b/src/thirdparty/unrar/crypt3.cpp
index 7441e7842..ffaced56d 100644
--- a/src/thirdparty/unrar/crypt3.cpp
+++ b/src/thirdparty/unrar/crypt3.cpp
@@ -47,28 +47,28 @@ void CryptData::SetKey30(bool Encrypt,SecPassword *Password,const wchar *PwdW,co
memcpy(RawPsw+RawLength,Salt,SIZE_SALT30);
RawLength+=SIZE_SALT30;
}
- hash_context c;
- hash_initial(&c);
+ sha1_context c;
+ sha1_init(&c);
const int HashRounds=0x40000;
for (int I=0;I<HashRounds;I++)
{
- hash_process( &c, RawPsw, RawLength, false);
+ sha1_process( &c, RawPsw, RawLength, false);
byte PswNum[3];
PswNum[0]=(byte)I;
PswNum[1]=(byte)(I>>8);
PswNum[2]=(byte)(I>>16);
- hash_process( &c, PswNum, 3, false);
+ sha1_process( &c, PswNum, 3, false);
if (I%(HashRounds/16)==0)
{
- hash_context tempc=c;
+ sha1_context tempc=c;
uint32 digest[5];
- hash_final( &tempc, digest, false);
+ sha1_done( &tempc, digest, false);
AESInit[I/(HashRounds/16)]=(byte)digest[4];
}
}
uint32 digest[5];
- hash_final( &c, digest, false);
+ sha1_done( &c, digest, false);
for (int I=0;I<4;I++)
for (int J=0;J<4;J++)
AESKey[I*4+J]=(byte)(digest[I]>>(J*8));
diff --git a/src/thirdparty/unrar/dll.cpp b/src/thirdparty/unrar/dll.cpp
index f60928ee8..d8962d147 100644
--- a/src/thirdparty/unrar/dll.cpp
+++ b/src/thirdparty/unrar/dll.cpp
@@ -65,7 +65,10 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
Data->Cmd.Callback=r->Callback;
Data->Cmd.UserData=r->UserData;
- if (!Data->Arc.Open(ArcName,0))
+ // Open shared mode is added by request of dll users, who need to
+ // browse and unpack archives while downloading.
+ Data->Cmd.OpenShared = true;
+ if (!Data->Arc.Open(ArcName,FMF_OPENSHARED))
{
r->OpenResult=ERAR_EOPEN;
delete Data;
@@ -122,7 +125,7 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
}
else
r->CmtState=r->CmtSize=0;
- Data->Extract.ExtractArchiveInit(&Data->Cmd,Data->Arc);
+ Data->Extract.ExtractArchiveInit(Data->Arc);
return (HANDLE)Data;
}
catch (RAR_EXIT ErrCode)
@@ -135,7 +138,7 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
delete Data;
return NULL;
}
- catch (std::bad_alloc) // Catch 'new' exception.
+ catch (std::bad_alloc&) // Catch 'new' exception.
{
r->OpenResult=ERAR_NO_MEMORY;
if (Data != NULL)
@@ -339,7 +342,7 @@ int PASCAL ProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestNa
wcscpy(Data->Cmd.Command,Operation==RAR_EXTRACT ? L"X":L"T");
Data->Cmd.Test=Operation!=RAR_EXTRACT;
bool Repeat=false;
- Data->Extract.ExtractCurrentFile(&Data->Cmd,Data->Arc,Data->HeaderSize,Repeat);
+ Data->Extract.ExtractCurrentFile(Data->Arc,Data->HeaderSize,Repeat);
// Now we process extra file information if any.
//
@@ -351,13 +354,13 @@ int PASCAL ProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestNa
while (Data->Arc.IsOpened() && Data->Arc.ReadHeader()!=0 &&
Data->Arc.GetHeaderType()==HEAD_SERVICE)
{
- Data->Extract.ExtractCurrentFile(&Data->Cmd,Data->Arc,Data->HeaderSize,Repeat);
+ Data->Extract.ExtractCurrentFile(Data->Arc,Data->HeaderSize,Repeat);
Data->Arc.SeekToNext();
}
Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
}
}
- catch (std::bad_alloc)
+ catch (std::bad_alloc&)
{
return ERAR_NO_MEMORY;
}
diff --git a/src/thirdparty/unrar/dll.rc b/src/thirdparty/unrar/dll.rc
index df361fdd0..b9caa867d 100644
--- a/src/thirdparty/unrar/dll.rc
+++ b/src/thirdparty/unrar/dll.rc
@@ -2,8 +2,8 @@
#include <commctrl.h>
VS_VERSION_INFO VERSIONINFO
-FILEVERSION 5, 1, 100, 1066
-PRODUCTVERSION 5, 1, 100, 1066
+FILEVERSION 5, 10, 1, 1173
+PRODUCTVERSION 5, 10, 1, 1173
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
{
@@ -14,9 +14,9 @@ FILETYPE VFT_APP
VALUE "CompanyName", "Alexander Roshal\0"
VALUE "ProductName", "RAR decompression library\0"
VALUE "FileDescription", "RAR decompression library\0"
- VALUE "FileVersion", "5.1.0\0"
- VALUE "ProductVersion", "5.1.0\0"
- VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2013\0"
+ VALUE "FileVersion", "5.10.1\0"
+ VALUE "ProductVersion", "5.10.1\0"
+ VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2014\0"
VALUE "OriginalFilename", "Unrar.dll\0"
}
}
diff --git a/src/thirdparty/unrar/errhnd.cpp b/src/thirdparty/unrar/errhnd.cpp
index fc7819f58..6486e400d 100644
--- a/src/thirdparty/unrar/errhnd.cpp
+++ b/src/thirdparty/unrar/errhnd.cpp
@@ -1,6 +1,5 @@
#include "rar.hpp"
-
ErrorHandler::ErrorHandler()
{
Clean();
@@ -22,7 +21,7 @@ void ErrorHandler::Clean()
void ErrorHandler::MemoryError()
{
MemoryErrorMsg();
- Throw(RARX_MEMORY);
+ Exit(RARX_MEMORY);
}
@@ -30,22 +29,20 @@ void ErrorHandler::OpenError(const wchar *FileName)
{
#ifndef SILENT
OpenErrorMsg(FileName);
- Throw(RARX_OPEN);
+ Exit(RARX_OPEN);
#endif
}
void ErrorHandler::CloseError(const wchar *FileName)
{
-#ifndef SILENT
if (!UserBreak)
{
- Log(NULL,St(MErrFClose),FileName);
+ uiMsg(UIERROR_FILECLOSE,FileName);
SysErrMsg();
}
-#endif
#if !defined(SILENT) || defined(RARDLL)
- Throw(RARX_FATAL);
+ Exit(RARX_FATAL);
#endif
}
@@ -56,7 +53,7 @@ void ErrorHandler::ReadError(const wchar *FileName)
ReadErrorMsg(FileName);
#endif
#if !defined(SILENT) || defined(RARDLL)
- Throw(RARX_FATAL);
+ Exit(RARX_FATAL);
#endif
}
@@ -67,9 +64,7 @@ bool ErrorHandler::AskRepeatRead(const wchar *FileName)
if (!Silent)
{
SysErrMsg();
- mprintf(L"\n");
- Log(NULL,St(MErrRead),FileName);
- return Ask(St(MRetryAbort))==1;
+ return uiAskRepeatRead(FileName);
}
#endif
return false;
@@ -82,7 +77,7 @@ void ErrorHandler::WriteError(const wchar *ArcName,const wchar *FileName)
WriteErrorMsg(ArcName,FileName);
#endif
#if !defined(SILENT) || defined(RARDLL)
- Throw(RARX_WRITE);
+ Exit(RARX_WRITE);
#endif
}
@@ -90,12 +85,10 @@ void ErrorHandler::WriteError(const wchar *ArcName,const wchar *FileName)
#ifdef _WIN_ALL
void ErrorHandler::WriteErrorFAT(const wchar *FileName)
{
-#if !defined(SILENT) && !defined(SFX_MODULE)
SysErrMsg();
- Log(NULL,St(MNTFSRequired),FileName);
-#endif
+ uiMsg(UIERROR_NTFSREQUIRED,FileName);
#if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL)
- Throw(RARX_WRITE);
+ Exit(RARX_WRITE);
#endif
}
#endif
@@ -107,9 +100,7 @@ bool ErrorHandler::AskRepeatWrite(const wchar *FileName,bool DiskFull)
if (!Silent)
{
SysErrMsg();
- mprintf(L"\n");
- Log(NULL,St(DiskFull ? MNotEnoughDisk:MErrWrite),FileName);
- return Ask(St(MRetryAbort))==1;
+ return uiAskRepeatWrite(FileName,DiskFull);
}
#endif
return false;
@@ -118,15 +109,13 @@ bool ErrorHandler::AskRepeatWrite(const wchar *FileName,bool DiskFull)
void ErrorHandler::SeekError(const wchar *FileName)
{
-#ifndef SILENT
if (!UserBreak)
{
- Log(NULL,St(MErrSeek),FileName);
+ uiMsg(UIERROR_FILESEEK,FileName);
SysErrMsg();
}
-#endif
#if !defined(SILENT) || defined(RARDLL)
- Throw(RARX_FATAL);
+ Exit(RARX_FATAL);
#endif
}
@@ -136,21 +125,26 @@ void ErrorHandler::GeneralErrMsg(const wchar *fmt,...)
va_list arglist;
va_start(arglist,fmt);
wchar Msg[1024];
+#ifdef _ANDROID
+ // vswprintf does not work in Android NDK. Conversion below should be ok
+ // as long as we do not pass Unicode strings in arguments.
+ char fmtA[NM],MsgA[ASIZE(Msg)];
+ WideToChar(fmt,fmtA,ASIZE(fmtA));
+ vsnprintf(MsgA,ASIZE(MsgA),fmtA,arglist);
+ CharToWide(MsgA,Msg,ASIZE(Msg));
+#else
vswprintf(Msg,ASIZE(Msg),fmt,arglist);
-#ifndef SILENT
- Log(NULL,L"%ls",Msg);
- mprintf(L"\n");
- SysErrMsg();
#endif
+ uiMsg(UIERROR_GENERALERRMSG,Msg);
+ SysErrMsg();
va_end(arglist);
}
void ErrorHandler::MemoryErrorMsg()
{
-#ifndef SILENT
- Log(NULL,St(MErrOutMem));
-#endif
+ uiMsg(UIERROR_MEMORY);
+ SetErrorCode(RARX_MEMORY);
}
@@ -162,11 +156,9 @@ void ErrorHandler::OpenErrorMsg(const wchar *FileName)
void ErrorHandler::OpenErrorMsg(const wchar *ArcName,const wchar *FileName)
{
-#ifndef SILENT
- if (FileName!=NULL)
- Log(ArcName,St(MCannotOpen),FileName);
+ uiMsg(UIERROR_FILEOPEN,ArcName,FileName);
SysErrMsg();
-#endif
+ SetErrorCode(RARX_OPEN);
}
@@ -178,37 +170,9 @@ void ErrorHandler::CreateErrorMsg(const wchar *FileName)
void ErrorHandler::CreateErrorMsg(const wchar *ArcName,const wchar *FileName)
{
-#ifndef SILENT
- Log(ArcName,St(MCannotCreate),FileName);
-
-#if defined(_WIN_ALL) && defined(MAX_PATH)
- CheckLongPathErrMsg(FileName);
-#endif
-
+ uiMsg(UIERROR_FILECREATE,ArcName,FileName);
SysErrMsg();
-#endif
-}
-
-
-// Check the path length and display the error message if it is too long.
-void ErrorHandler::CheckLongPathErrMsg(const wchar *FileName)
-{
-#if defined(_WIN_ALL) && !defined (SILENT) && defined(MAX_PATH)
- if (GetLastError()==ERROR_PATH_NOT_FOUND)
- {
- size_t NameLength=wcslen(FileName);
- if (!IsFullPath(FileName))
- {
- wchar CurDir[NM];
- GetCurrentDirectory(ASIZE(CurDir),CurDir);
- NameLength+=wcslen(CurDir)+1;
- }
- if (NameLength>MAX_PATH)
- {
- Log(NULL,St(MMaxPathLimit),MAX_PATH);
- }
- }
-#endif
+ SetErrorCode(RARX_CREATE);
}
@@ -220,26 +184,45 @@ void ErrorHandler::ReadErrorMsg(const wchar *FileName)
void ErrorHandler::ReadErrorMsg(const wchar *ArcName,const wchar *FileName)
{
-#ifndef SILENT
- Log(ArcName,St(MErrRead),FileName);
+ uiMsg(UIERROR_FILEREAD,ArcName,FileName);
SysErrMsg();
-#endif
+ SetErrorCode(RARX_FATAL);
}
void ErrorHandler::WriteErrorMsg(const wchar *ArcName,const wchar *FileName)
{
-#ifndef SILENT
- Log(ArcName,St(MErrWrite),FileName);
+ uiMsg(UIERROR_FILEWRITE,ArcName,FileName);
SysErrMsg();
-#endif
+ SetErrorCode(RARX_WRITE);
+}
+
+
+void ErrorHandler::ArcBrokenMsg(const wchar *ArcName)
+{
+ uiMsg(UIERROR_ARCBROKEN,ArcName);
+ SetErrorCode(RARX_CRC);
+}
+
+
+void ErrorHandler::ChecksumFailedMsg(const wchar *ArcName,const wchar *FileName)
+{
+ uiMsg(UIERROR_CHECKSUM,ArcName,FileName);
+ SetErrorCode(RARX_CRC);
+}
+
+
+void ErrorHandler::UnknownMethodMsg(const wchar *ArcName,const wchar *FileName)
+{
+ uiMsg(UIERROR_UNKNOWNMETHOD,ArcName,FileName);
+ ErrHandler.SetErrorCode(RARX_FATAL);
}
void ErrorHandler::Exit(RAR_EXIT ExitCode)
{
#ifndef GUI
- Alarm();
+ uiAlarm(UIALARM_ERROR);
#endif
Throw(ExitCode);
}
@@ -324,7 +307,6 @@ void ErrorHandler::SetSignalHandlers(bool Enable)
#ifndef GUI
#ifdef _WIN_ALL
SetConsoleCtrlHandler(Enable ? ProcessSignal:NULL,TRUE);
-// signal(SIGBREAK,Enable ? ProcessSignal:SIG_IGN);
#else
signal(SIGINT,Enable ? ProcessSignal:SIG_IGN);
signal(SIGTERM,Enable ? ProcessSignal:SIG_IGN);
@@ -372,7 +354,7 @@ void ErrorHandler::SysErrMsg()
*EndMsg=0;
EndMsg++;
}
- Log(NULL,L"\n%ls",CurMsg);
+ uiMsg(UIERROR_SYSERRMSG,CurMsg);
CurMsg=EndMsg;
}
}
@@ -382,12 +364,18 @@ void ErrorHandler::SysErrMsg()
#if defined(_UNIX) || defined(_EMX)
if (errno!=0)
{
+#ifdef _ANDROID
+ // Android NDK sets errno to confusing "not a typewriter" ENOTTY code
+ // after write error reported by write().
+ if (errno == ENOTTY)
+ return;
+#endif
char *err=strerror(errno);
if (err!=NULL)
{
- wchar MsgW[1024];
- CharToWide(err,MsgW,ASIZE(MsgW));
- Log(NULL,L"\n%s",MsgW);
+ wchar Msg[1024];
+ CharToWide(err,Msg,ASIZE(Msg));
+ uiMsg(UIERROR_SYSERRMSG,Msg);
}
}
#endif
diff --git a/src/thirdparty/unrar/errhnd.hpp b/src/thirdparty/unrar/errhnd.hpp
index cf64cc1b4..1f5878d39 100644
--- a/src/thirdparty/unrar/errhnd.hpp
+++ b/src/thirdparty/unrar/errhnd.hpp
@@ -44,13 +44,15 @@ class ErrorHandler
void OpenErrorMsg(const wchar *ArcName,const wchar *FileName);
void CreateErrorMsg(const wchar *FileName);
void CreateErrorMsg(const wchar *ArcName,const wchar *FileName);
- void CheckLongPathErrMsg(const wchar *FileName);
void ReadErrorMsg(const wchar *FileName);
void ReadErrorMsg(const wchar *ArcName,const wchar *FileName);
void WriteErrorMsg(const wchar *ArcName,const wchar *FileName);
+ void ArcBrokenMsg(const wchar *ArcName);
+ void ChecksumFailedMsg(const wchar *ArcName,const wchar *FileName);
+ void UnknownMethodMsg(const wchar *ArcName,const wchar *FileName);
void Exit(RAR_EXIT ExitCode);
void SetErrorCode(RAR_EXIT Code);
- RAR_EXIT GetErrorCode() {return(ExitCode);}
+ RAR_EXIT GetErrorCode() {return ExitCode;}
uint GetErrorCount() {return ErrCount;}
void SetSignalHandlers(bool Enable);
void Throw(RAR_EXIT Code);
diff --git a/src/thirdparty/unrar/extract.cpp b/src/thirdparty/unrar/extract.cpp
index 746904001..8daabfaf5 100644
--- a/src/thirdparty/unrar/extract.cpp
+++ b/src/thirdparty/unrar/extract.cpp
@@ -2,6 +2,8 @@
CmdExtract::CmdExtract(CommandData *Cmd)
{
+ CmdExtract::Cmd=Cmd;
+
*ArcName=0;
*DestFileName=0;
@@ -21,7 +23,7 @@ CmdExtract::~CmdExtract()
}
-void CmdExtract::DoExtract(CommandData *Cmd)
+void CmdExtract::DoExtract()
{
PasswordCancelled=false;
DataIO.SetCurrentCommand(Cmd->Command[0]);
@@ -39,7 +41,7 @@ void CmdExtract::DoExtract(CommandData *Cmd)
SecPassword PrevCmdPassword;
PrevCmdPassword=Cmd->Password;
- EXTRACT_ARC_CODE Code=ExtractArchive(Cmd);
+ EXTRACT_ARC_CODE Code=ExtractArchive();
// Restore Cmd->Password, which could be changed in IsArchive() call
// for next header encrypted archive.
@@ -56,9 +58,7 @@ void CmdExtract::DoExtract(CommandData *Cmd)
ErrHandler.GetErrorCode()!=RARX_BADPWD) // Not in case of wrong archive password.
{
if (!PasswordCancelled)
- {
- mprintf(St(MExtrNoFiles));
- }
+ uiMsg(UIERROR_NOFILESTOEXTRACT,ArcName);
ErrHandler.SetErrorCode(RARX_NOFILES);
}
#ifndef GUI
@@ -75,7 +75,7 @@ void CmdExtract::DoExtract(CommandData *Cmd)
}
-void CmdExtract::ExtractArchiveInit(CommandData *Cmd,Archive &Arc)
+void CmdExtract::ExtractArchiveInit(Archive &Arc)
{
DataIO.UnpArcSize=Arc.FileLength();
@@ -100,14 +100,11 @@ void CmdExtract::ExtractArchiveInit(CommandData *Cmd,Archive &Arc)
}
-EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
+EXTRACT_ARC_CODE CmdExtract::ExtractArchive()
{
Archive Arc(Cmd);
if (!Arc.WOpen(ArcName))
- {
- ErrHandler.SetErrorCode(RARX_OPEN);
return EXTRACT_ARC_NEXT;
- }
if (!Arc.IsArchive(true))
{
@@ -126,7 +123,7 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
if (Arc.Volume && !Arc.FirstVolume)
{
wchar FirstVolName[NM];
- VolNameToFirstName(ArcName,FirstVolName,Arc.NewNumbering);
+ VolNameToFirstName(ArcName,FirstVolName,ASIZE(FirstVolName),Arc.NewNumbering);
// If several volume names from same volume set are specified
// and current volume is not first in set and first volume is present
@@ -162,21 +159,20 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
DataIO.TotalArcSize+=VolumeSetSize;
}
- ExtractArchiveInit(Cmd,Arc);
+ ExtractArchiveInit(Arc);
if (*Cmd->Command=='T' || *Cmd->Command=='I')
Cmd->Test=true;
-#ifndef GUI
if (*Cmd->Command=='I')
+ {
+#ifndef GUI
Cmd->DisablePercentage=true;
- else
- if (Cmd->Test)
- mprintf(St(MExtrTest),ArcName);
- else
- mprintf(St(MExtracting),ArcName);
#endif
+ }
+ else
+ uiStartArchiveExtract(!Cmd->Test,ArcName);
Arc.ViewComment();
@@ -187,7 +183,7 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
bool Repeat=false;
- if (!ExtractCurrentFile(Cmd,Arc,Size,Repeat))
+ if (!ExtractCurrentFile(Arc,Size,Repeat))
if (Repeat)
{
// If we started extraction from not first volume and need to
@@ -210,7 +206,7 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
}
-bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize,bool &Repeat)
+bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat)
{
wchar Command=Cmd->Command[0];
if (HeaderSize==0)
@@ -287,7 +283,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
{
wchar CurVolName[NM];
wcsncpyz(CurVolName,ArcName,ASIZE(CurVolName));
- VolNameToFirstName(ArcName,ArcName,Arc.NewNumbering);
+ VolNameToFirstName(ArcName,ArcName,ASIZE(ArcName),Arc.NewNumbering);
if (wcsicomp(ArcName,CurVolName)!=0 && FileExist(ArcName))
{
@@ -300,7 +296,6 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (!ReconstructDone)
{
ReconstructDone=true;
-
if (RecVolumesRestore(Cmd,Arc.FileName,true))
{
Repeat=true;
@@ -345,7 +340,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
{
if (ExactMatch)
{
- Log(Arc.FileName,St(MUnpCannotMerge),ArcFileName);
+ uiMsg(UIERROR_NEEDPREVVOL,Arc.FileName,ArcFileName);
#ifdef RARDLL
Cmd->DllError=ERAR_BAD_DATA;
#endif
@@ -359,8 +354,13 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (ExactMatch || (SkipSolid=Arc.Solid)!=0)
{
+ // First common call of uiStartFileExtract. It is done before overwrite
+ // prompts, so if SkipSolid state is changed below, we'll need to make
+ // additional uiStartFileExtract calls with updated parameters.
+ if (!uiStartFileExtract(ArcFileName,!Cmd->Test,Cmd->Test && Command!='I',SkipSolid))
+ return false;
- ExtrPrepareName(Cmd,Arc,ArcFileName,DestFileName,ASIZE(DestFileName));
+ ExtrPrepareName(Arc,ArcFileName,DestFileName,ASIZE(DestFileName));
// DestFileName can be set empty in case of excessive -ap switch.
ExtrFile=!SkipSolid && *DestFileName!=0 && !Arc.FileHead.SplitBefore;
@@ -390,10 +390,10 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (Arc.FileHead.Encrypted)
{
#ifdef RARDLL
- if (!ExtrDllGetPassword(Cmd))
+ if (!ExtrDllGetPassword())
return false;
#else
- if (!ExtrGetPassword(Cmd,Arc,ArcFileName))
+ if (!ExtrGetPassword(Arc,ArcFileName))
{
PasswordCancelled=true;
return false;
@@ -424,12 +424,13 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (!CheckUnpVer(Arc,ArcFileName))
{
ExtrFile=false;
- ErrHandler.SetErrorCode(RARX_WARNING);
+ ErrHandler.SetErrorCode(RARX_FATAL);
#ifdef RARDLL
Cmd->DllError=ERAR_UNKNOWN_FORMAT;
#endif
}
+
File CurFile;
bool LinkEntry=Arc.FileHead.RedirType!=FSREDIR_NONE;
@@ -440,7 +441,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
// Overwrite prompt for symbolic and hard links.
bool UserReject=false;
if (FileExist(DestFileName) && !UserReject)
- FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime);
+ FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime);
if (UserReject)
ExtrFile=false;
}
@@ -451,18 +452,25 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (!ExtrFile || Command=='P' || Command=='I' || Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH)
return true;
TotalFileCount++;
- ExtrCreateDir(Cmd,Arc,ArcFileName);
+ ExtrCreateDir(Arc,ArcFileName);
return true;
}
else
if (ExtrFile) // Create files and file copies (FSREDIR_FILECOPY).
- ExtrFile=ExtrCreateFile(Cmd,Arc,CurFile);
+ ExtrFile=ExtrCreateFile(Arc,CurFile);
if (!ExtrFile && Arc.Solid)
{
SkipSolid=true;
ExtrFile=true;
+ // We changed SkipSolid, so we need to call uiStartFileExtract
+ // with "Skip" parameter to change the operation status
+ // from "extracting" to "skipping". For example, it can be necessary
+ // if user answered "No" to overwrite prompt when unpacking
+ // a solid archive.
+ if (!uiStartFileExtract(ArcFileName,false,false,true))
+ return false;
}
if (ExtrFile)
{
@@ -472,7 +480,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
{
if (!TestMode && Command!='P' && CurFile.IsDevice())
{
- Log(Arc.FileName,St(MInvalidName),DestFileName);
+ uiMsg(UIERROR_INVALIDNAME,Arc.FileName,DestFileName);
ErrHandler.WriteError(Arc.FileName,DestFileName);
}
TotalFileCount++;
@@ -520,7 +528,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
memcmp(Arc.FileHead.PswCheck,PswCheck,SIZE_PSWCHECK)!=0 &&
!Arc.BrokenHeader)
{
- Log(Arc.FileName,St(MWrongPassword));
+ uiMsg(UIERROR_BADPSW,Arc.FileName);
ErrHandler.SetErrorCode(RARX_BADPWD);
WrongPassword=true;
}
@@ -550,12 +558,12 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (Type==FSREDIR_HARDLINK || Type==FSREDIR_FILECOPY)
{
wchar NameExisting[NM];
- ExtrPrepareName(Cmd,Arc,Arc.FileHead.RedirName,NameExisting,ASIZE(NameExisting));
+ ExtrPrepareName(Arc,Arc.FileHead.RedirName,NameExisting,ASIZE(NameExisting));
if (FileCreateMode && *NameExisting!=0) // *NameExisting can be 0 in case of excessive -ap switch.
if (Type==FSREDIR_HARDLINK)
LinkSuccess=ExtractHardlink(DestFileName,NameExisting,ASIZE(NameExisting));
else
- LinkSuccess=ExtractFileCopy(Cmd,CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting));
+ LinkSuccess=ExtractFileCopy(CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting));
}
else
if (Type==FSREDIR_UNIXSYMLINK || Type==FSREDIR_WINSYMLINK || Type==FSREDIR_JUNCTION)
@@ -565,9 +573,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
}
else
{
-#ifndef SFX_MODULE
- Log(Arc.FileName,St(MUnknownExtra),DestFileName);
-#endif
+ uiMsg(UIERROR_UNKNOWNEXTRA, Arc.FileName, DestFileName);
LinkSuccess=false;
}
@@ -588,6 +594,13 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
UnstoreFile(DataIO,Arc.FileHead.UnpSize);
else
{
+#ifdef _ANDROID
+ // malloc and new do not report memory allocation errors
+ // in Android, so if free memory is set, check it here
+ // trying to prevent crash.
+ if (Cmd->FreeMem!=0 && Cmd->FreeMem < Arc.FileHead.WinSize)
+ throw std::bad_alloc();
+#endif
Unp->Init(Arc.FileHead.WinSize,Arc.FileHead.Solid);
Unp->SetDestSize(Arc.FileHead.UnpSize);
#ifndef SFX_MODULE
@@ -630,13 +643,9 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
if (!WrongPassword)
if (Arc.FileHead.Encrypted && (!Arc.FileHead.UsePswCheck ||
Arc.BrokenHeader) && !AnySolidDataUnpackedWell)
- {
- Log(Arc.FileName,St(MEncrBadCRC),ArcFileName);
- }
+ uiMsg(UIERROR_CHECKSUMENC,Arc.FileName,ArcFileName);
else
- {
- Log(Arc.FileName,St(MCRCFailed),ArcFileName);
- }
+ uiMsg(UIERROR_CHECKSUM,Arc.FileName,ArcFileName);
BrokenFile=true;
ErrHandler.SetErrorCode(RARX_CRC);
#ifdef RARDLL
@@ -684,8 +693,9 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
CurFile.SetCloseFileTime(
Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.FileHead.mtime,
Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.FileHead.atime);
- if (!Cmd->IgnoreGeneralAttr)
- SetFileAttr(CurFile.FileName,Arc.FileHead.FileAttr);
+ if (!Cmd->IgnoreGeneralAttr && !SetFileAttr(CurFile.FileName,Arc.FileHead.FileAttr))
+ uiMsg(UIERROR_FILEATTR,Arc.FileName,CurFile.FileName);
+
PrevExtracted=true;
}
}
@@ -706,6 +716,9 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS
void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize)
{
+ // 512 KB and larger buffer reported to reduce performance on old XP
+ // computers with WDC WD2000JD HDD. According to test made by user
+ // 256 KB buffer is optimal.
Array<byte> Buffer(0x40000);
while (1)
{
@@ -720,19 +733,15 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize)
}
-bool CmdExtract::ExtractFileCopy(CommandData *Cmd,File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
+bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
{
-#ifdef _WIN_ALL
- UnixSlashToDos(NameExisting,NameExisting,NameExistingSize);
-#elif defined(_UNIX)
- DosSlashToUnix(NameExisting,NameExisting,NameExistingSize);
-#endif
+ SlashToNative(NameExisting,NameExisting,NameExistingSize);
+
File Existing;
- if (!Existing.Open(NameExisting))
+ if (!Existing.WOpen(NameExisting))
{
- ErrHandler.OpenErrorMsg(ArcName,NameExisting);
- Log(ArcName,St(MCopyError),NameExisting,NameNew);
- Log(ArcName,St(MCopyErrorHint));
+ uiMsg(UIERROR_FILECOPY,ArcName,NameExisting,NameNew);
+ uiMsg(UIERROR_FILECOPYHINT,ArcName);
#ifdef RARDLL
Cmd->DllError=ERAR_EREFERENCE;
#endif
@@ -756,7 +765,7 @@ bool CmdExtract::ExtractFileCopy(CommandData *Cmd,File &New,wchar *ArcName,wchar
}
-void CmdExtract::ExtrPrepareName(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize)
+void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize)
{
wcsncpyz(DestName,Cmd->ExtrPath,DestSize);
@@ -772,7 +781,7 @@ void CmdExtract::ExtrPrepareName(CommandData *Cmd,Archive &Arc,const wchar *ArcF
if (Cmd->AppendArcNameToPath)
{
wcsncatz(DestName,PointToName(Arc.FirstVolumeName),DestSize);
- SetExt(DestName,NULL);
+ SetExt(DestName,NULL,DestSize);
AddEndSlash(DestName,DestSize);
}
#endif
@@ -826,7 +835,7 @@ void CmdExtract::ExtrPrepareName(CommandData *Cmd,Archive &Arc,const wchar *ArcF
#ifdef RARDLL
-bool CmdExtract::ExtrDllGetPassword(CommandData *Cmd)
+bool CmdExtract::ExtrDllGetPassword()
{
if (!Cmd->Password.IsSet())
{
@@ -858,12 +867,14 @@ bool CmdExtract::ExtrDllGetPassword(CommandData *Cmd)
#ifndef RARDLL
-bool CmdExtract::ExtrGetPassword(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName)
+bool CmdExtract::ExtrGetPassword(Archive &Arc,const wchar *ArcFileName)
{
if (!Password.IsSet())
{
- if (!GetPassword(PASSWORD_FILE,ArcFileName,&Password))
+ if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Password))
{
+ uiMsg(UIERROR_INCERRCOUNT);
+
return false;
}
}
@@ -872,12 +883,12 @@ bool CmdExtract::ExtrGetPassword(CommandData *Cmd,Archive &Arc,const wchar *ArcF
if (!PasswordAll && !Arc.FileHead.Solid)
{
eprintf(St(MUseCurPsw),ArcFileName);
- switch(Cmd->AllYes ? 1:Ask(St(MYesNoAll)))
+ switch(Cmd->AllYes ? 1 : Ask(St(MYesNoAll)))
{
case -1:
ErrHandler.Exit(RARX_USERBREAK);
case 2:
- if (!GetPassword(PASSWORD_FILE,ArcFileName,&Password))
+ if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Password))
return false;
break;
case 3:
@@ -912,7 +923,7 @@ void CmdExtract::ConvertDosPassword(Archive &Arc,SecPassword &DestPwd)
#endif
-void CmdExtract::ExtrCreateDir(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName)
+void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName)
{
if (Cmd->Test)
{
@@ -933,7 +944,7 @@ void CmdExtract::ExtrCreateDir(CommandData *Cmd,Archive &Arc,const wchar *ArcFil
// File with name same as this directory exists. Propose user
// to overwrite it.
bool UserReject;
- FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime);
+ FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime);
DirExist=false;
}
if (!DirExist)
@@ -959,8 +970,7 @@ void CmdExtract::ExtrCreateDir(CommandData *Cmd,Archive &Arc,const wchar *ArcFil
}
else
{
- Log(Arc.FileName,St(MExtrErrMkDir),DestFileName);
- ErrHandler.CheckLongPathErrMsg(DestFileName);
+ uiMsg(UIERROR_DIRCREATE,Arc.FileName,DestFileName);
ErrHandler.SysErrMsg();
#ifdef RARDLL
Cmd->DllError=ERAR_ECREATE;
@@ -982,7 +992,7 @@ void CmdExtract::ExtrCreateDir(CommandData *Cmd,Archive &Arc,const wchar *ArcFil
}
-bool CmdExtract::ExtrCreateFile(CommandData *Cmd,Archive &Arc,File &CurFile)
+bool CmdExtract::ExtrCreateFile(Archive &Arc,File &CurFile)
{
bool Success=true;
wchar Command=Cmd->Command[0];
@@ -995,29 +1005,29 @@ bool CmdExtract::ExtrCreateFile(CommandData *Cmd,Archive &Arc,File &CurFile)
bool UserReject;
// Specify "write only" mode to avoid OpenIndiana NAS problems
// with SetFileTime and read+write files.
- if (!FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))
+ if (!FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))
{
Success=false;
if (!UserReject)
{
ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);
- ErrHandler.SetErrorCode(RARX_CREATE);
#ifdef RARDLL
Cmd->DllError=ERAR_ECREATE;
#endif
if (!IsNameUsable(DestFileName))
{
- Log(Arc.FileName,St(MCorrectingName));
+ uiMsg(UIMSG_CORRECTINGNAME,Arc.FileName);
+
wchar OrigName[ASIZE(DestFileName)];
wcsncpyz(OrigName,DestFileName,ASIZE(OrigName));
MakeNameUsable(DestFileName,true);
CreatePath(DestFileName,true);
- if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))
+ if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))
{
#ifndef SFX_MODULE
- Log(Arc.FileName,St(MRenaming),OrigName,DestFileName);
+ uiMsg(UIERROR_RENAMING,Arc.FileName,OrigName,DestFileName);
#endif
Success=true;
}
@@ -1051,13 +1061,8 @@ bool CmdExtract::CheckUnpVer(Archive &Arc,const wchar *ArcFileName)
if (WrongVer)
{
-#ifndef SILENT
- Log(Arc.FileName,St(MUnknownMeth),ArcFileName);
-#ifndef SFX_MODULE
-// Log(Arc.FileName,St(MVerRequired),Arc.FileHead.UnpVer/10,Arc.FileHead.UnpVer%10);
- Log(Arc.FileName,St(MNewerRAR));
-#endif
-#endif
+ ErrHandler.UnknownMethodMsg(Arc.FileName,ArcFileName);
+ uiMsg(UIERROR_NEWERRAR,Arc.FileName);
}
return !WrongVer;
}
diff --git a/src/thirdparty/unrar/extract.hpp b/src/thirdparty/unrar/extract.hpp
index 817bf4d6f..1539ed61a 100644
--- a/src/thirdparty/unrar/extract.hpp
+++ b/src/thirdparty/unrar/extract.hpp
@@ -6,23 +6,25 @@ enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT};
class CmdExtract
{
private:
- EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
- bool ExtractFileCopy(CommandData *Cmd,File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize);
- void ExtrPrepareName(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize);
+ EXTRACT_ARC_CODE ExtractArchive();
+ bool ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize);
+ void ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize);
#ifdef RARDLL
- bool ExtrDllGetPassword(CommandData *Cmd);
+ bool ExtrDllGetPassword();
#else
- bool ExtrGetPassword(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName);
+ bool ExtrGetPassword(Archive &Arc,const wchar *ArcFileName);
#endif
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
void ConvertDosPassword(Archive &Arc,SecPassword &DestPwd);
#endif
- void ExtrCreateDir(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName);
- bool ExtrCreateFile(CommandData *Cmd,Archive &Arc,File &CurFile);
+ void ExtrCreateDir(Archive &Arc,const wchar *ArcFileName);
+ bool ExtrCreateFile(Archive &Arc,File &CurFile);
bool CheckUnpVer(Archive &Arc,const wchar *ArcFileName);
RarTime StartTime; // time when extraction started
+ CommandData *Cmd;
+
ComprDataIO DataIO;
Unpack *Unp;
unsigned long TotalFileCount;
@@ -49,10 +51,9 @@ class CmdExtract
public:
CmdExtract(CommandData *Cmd);
~CmdExtract();
- void DoExtract(CommandData *Cmd);
- void ExtractArchiveInit(CommandData *Cmd,Archive &Arc);
- bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize,
- bool &Repeat);
+ void DoExtract();
+ void ExtractArchiveInit(Archive &Arc);
+ bool ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat);
static void UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize);
};
diff --git a/src/thirdparty/unrar/filcreat.cpp b/src/thirdparty/unrar/filcreat.cpp
index 62103cd99..8b20b3fa9 100644
--- a/src/thirdparty/unrar/filcreat.cpp
+++ b/src/thirdparty/unrar/filcreat.cpp
@@ -4,8 +4,7 @@
// It is useful we we need to overwrite an existing folder or file,
// but need user confirmation for that.
bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize,
- OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize,
- RarTime *FileTime,bool WriteOnly)
+ bool *UserReject,int64 FileSize,RarTime *FileTime,bool WriteOnly)
{
if (UserReject!=NULL)
*UserReject=false;
@@ -30,77 +29,18 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize,
// autorename below can change the name, so we need to check it again.
ShortNameChanged=false;
#endif
- if (Mode==OVERWRITE_NONE)
+ UIASKREP_RESULT Choice=uiAskReplaceEx(Cmd,Name,MaxNameSize,FileSize,FileTime,(NewFile==NULL ? UIASKREP_F_NORENAME:0));
+
+ if (Choice==UIASKREP_R_REPLACE)
+ break;
+ if (Choice==UIASKREP_R_SKIP)
{
if (UserReject!=NULL)
*UserReject=true;
return false;
}
-
- // Must be before Cmd->AllYes check or -y switch would override -or.
- if (Mode==OVERWRITE_AUTORENAME)
- {
- if (!GetAutoRenamedName(Name,MaxNameSize))
- Mode=OVERWRITE_DEFAULT;
- continue;
- }
-
-#ifdef SILENT
- Mode=OVERWRITE_ALL;
-#endif
-
- // This check must be after OVERWRITE_AUTORENAME processing or -y switch
- // would override -or.
- if (Cmd->AllYes || Mode==OVERWRITE_ALL)
- break;
-
- if (Mode==OVERWRITE_DEFAULT || Mode==OVERWRITE_FORCE_ASK)
- {
- wchar NewName[NM];
- *NewName=0;
- eprintf(St(MFileExists),Name);
- int Choice=Ask(St(MYesNoAllRenQ));
- if (Choice==1)
- break;
- if (Choice==2)
- {
- if (UserReject!=NULL)
- *UserReject=true;
- return false;
- }
- if (Choice==3)
- {
- Cmd->Overwrite=OVERWRITE_ALL;
- break;
- }
- if (Choice==4)
- {
- if (UserReject!=NULL)
- *UserReject=true;
- Cmd->Overwrite=OVERWRITE_NONE;
- return false;
- }
- if (Choice==5)
- {
-#ifndef GUI
- mprintf(St(MAskNewName));
- if (!getwstr(NewName,ASIZE(NewName)))
- {
- // Process fwgets failure as if user answered 'No'.
- if (UserReject!=NULL)
- *UserReject=true;
- return false;
- }
-#endif
- if (PointToName(NewName)==NewName)
- SetName(Name,NewName,MaxNameSize);
- else
- wcsncpyz(Name,NewName,MaxNameSize);
- continue;
- }
- if (Choice==6)
- ErrHandler.Exit(RARX_USERBREAK);
- }
+ if (Choice==UIASKREP_R_CANCEL)
+ ErrHandler.Exit(RARX_USERBREAK);
}
uint FileMode=WriteOnly ? FMF_WRITE|FMF_SHAREREAD:FMF_UPDATE|FMF_SHAREREAD;
if (NewFile!=NULL && NewFile->Create(Name,FileMode))
@@ -114,15 +54,26 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize,
bool GetAutoRenamedName(wchar *Name,size_t MaxNameSize)
{
wchar NewName[NM];
- if (wcslen(Name)>ASIZE(NewName)-10)
+ size_t NameLength=wcslen(Name);
+#ifdef _ANDROID
+ if (NameLength>ASIZE(NewName)-10)
return false;
+#endif
wchar *Ext=GetExt(Name);
if (Ext==NULL)
- Ext=Name+wcslen(Name);
- *NewName=0;
+ Ext=Name+NameLength;
for (uint FileVer=1;;FileVer++)
{
+#ifdef _ANDROID // No swprintf in Android NDK r9.
+ uint NamePrefixLength=Ext-Name;
+ wcsncpy(NewName,Name,NamePrefixLength);
+ wcscpy(NewName+NamePrefixLength,L"(");
+ itoa(FileVer,NewName+NamePrefixLength+1);
+ wcscat(NewName,L")");
+ wcscat(NewName,Ext);
+#else
swprintf(NewName,ASIZE(NewName),L"%.*ls(%u)%ls",uint(Ext-Name),Name,FileVer,Ext);
+#endif
if (!FileExist(NewName))
{
wcsncpyz(Name,NewName,MaxNameSize);
@@ -201,7 +152,7 @@ bool UpdateExistingShortName(const wchar *Name)
File KeepShortFile;
bool Created=false;
if (!FileExist(Name))
- Created=KeepShortFile.Create(Name);
+ Created=KeepShortFile.Create(Name,FMF_WRITE|FMF_SHAREREAD);
// Now we rename the existing file from temporary name to original long name.
// Since its previous short name is occupied by another file, it should
diff --git a/src/thirdparty/unrar/filcreat.hpp b/src/thirdparty/unrar/filcreat.hpp
index a7d10a2df..e8368cd44 100644
--- a/src/thirdparty/unrar/filcreat.hpp
+++ b/src/thirdparty/unrar/filcreat.hpp
@@ -2,7 +2,7 @@
#define _RAR_FILECREATE_
bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize,
- OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize=INT64NDF,
+ bool *UserReject,int64 FileSize=INT64NDF,
RarTime *FileTime=NULL,bool WriteOnly=false);
bool GetAutoRenamedName(wchar *Name,size_t MaxNameSize);
diff --git a/src/thirdparty/unrar/file.cpp b/src/thirdparty/unrar/file.cpp
index 0da3f3d4a..4524fbeed 100644
--- a/src/thirdparty/unrar/file.cpp
+++ b/src/thirdparty/unrar/file.cpp
@@ -36,6 +36,7 @@ void File::operator = (File &SrcFile)
NewFile=SrcFile.NewFile;
LastWrite=SrcFile.LastWrite;
HandleType=SrcFile.HandleType;
+ wcsncpyz(FileName,SrcFile.FileName,ASIZE(FileName));
SrcFile.SkipClose=true;
}
@@ -110,7 +111,16 @@ bool File::Open(const wchar *Name,uint Mode)
return false;
}
#endif
- hNewFile=handle==-1 ? BAD_HANDLE:fdopen(handle,UpdateMode ? UPDATEBINARY:READBINARY);
+ if (handle==-1)
+ hNewFile=BAD_HANDLE;
+ else
+ {
+#ifdef FILE_USE_OPEN
+ hNewFile=handle;
+#else
+ hNewFile=fdopen(handle,UpdateMode ? UPDATEBINARY:READBINARY);
+#endif
+ }
if (hNewFile==BAD_HANDLE && errno==ENOENT)
ErrorType=FILE_NOTFOUND;
#endif
@@ -169,8 +179,12 @@ bool File::Create(const wchar *Name,uint Mode)
#else
char NameA[NM];
WideToChar(Name,NameA,ASIZE(NameA));
+#ifdef FILE_USE_OPEN
+ hFile=open(NameA,(O_CREAT|O_TRUNC) | (WriteMode ? O_WRONLY : O_RDWR));
+#else
hFile=fopen(NameA,WriteMode ? WRITEBINARY:CREATEBINARY);
#endif
+#endif
NewFile=true;
HandleType=FILE_HANDLENORMAL;
SkipClose=false;
@@ -192,7 +206,6 @@ bool File::WCreate(const wchar *Name,uint Mode)
{
if (Create(Name,Mode))
return true;
- ErrHandler.SetErrorCode(RARX_CREATE);
ErrHandler.CreateErrorMsg(Name);
return false;
}
@@ -212,8 +225,12 @@ bool File::Close()
if (HandleType==FILE_HANDLENORMAL)
Success=CloseHandle(hFile)==TRUE;
#else
+#ifdef FILE_USE_OPEN
+ Success=close(hFile)!=-1;
+#else
Success=fclose(hFile)!=EOF;
#endif
+#endif
}
hFile=BAD_HANDLE;
}
@@ -224,16 +241,6 @@ bool File::Close()
}
-void File::Flush()
-{
-#ifdef _WIN_ALL
- FlushFileBuffers(hFile);
-#else
- fflush(hFile);
-#endif
-}
-
-
bool File::Delete()
{
if (HandleType!=FILE_HANDLENORMAL)
@@ -272,7 +279,13 @@ void File::Write(const void *Data,size_t Size)
#else
// Cannot use the standard stdout here, because it already has wide orientation.
if (hFile==BAD_HANDLE)
- hFile=fdopen(dup(1),"w"); // Open new stdout stream.
+ {
+#ifdef FILE_USE_OPEN
+ hFile=dup(STDOUT_FILENO); // Open new stdout stream.
+#else
+ hFile=fdopen(dup(STDOUT_FILENO),"w"); // Open new stdout stream.
+#endif
+ }
#endif
}
while (1)
@@ -294,9 +307,14 @@ void File::Write(const void *Data,size_t Size)
else
Success=WriteFile(hFile,Data,(DWORD)Size,&Written,NULL)==TRUE;
#else
+#ifdef FILE_USE_OPEN
+ ssize_t Written=write(hFile,Data,Size);
+ Success=Written==Size;
+#else
int Written=fwrite(Data,1,Size,hFile);
Success=Written==Size && !ferror(hFile);
#endif
+#endif
if (!Success && AllowExceptions && HandleType==FILE_HANDLENORMAL)
{
#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(RARDLL)
@@ -309,7 +327,7 @@ void File::Write(const void *Data,size_t Size)
#endif
if (ErrHandler.AskRepeatWrite(FileName,false))
{
-#ifndef _WIN_ALL
+#if !defined(_WIN_ALL) && !defined(FILE_USE_OPEN)
clearerr(hFile);
#endif
if (Written<Size && Written>0)
@@ -376,8 +394,12 @@ int File::DirectRead(void *Data,size_t Size)
Size=MaxDeviceRead;
hFile=GetStdHandle(STD_INPUT_HANDLE);
#else
+#ifdef FILE_USE_OPEN
+ hFile=STDIN_FILENO;
+#else
hFile=stdin;
#endif
+#endif
}
#ifdef _WIN_ALL
DWORD Read;
@@ -402,6 +424,12 @@ int File::DirectRead(void *Data,size_t Size)
}
return Read;
#else
+#ifdef FILE_USE_OPEN
+ ssize_t ReadSize=read(hFile,Data,Size);
+ if (ReadSize==-1)
+ return -1;
+ return (int)ReadSize;
+#else
if (LastWrite)
{
fflush(hFile);
@@ -413,6 +441,7 @@ int File::DirectRead(void *Data,size_t Size)
return -1;
return (int)ReadSize;
#endif
+#endif
}
@@ -439,13 +468,17 @@ bool File::RawSeek(int64 Offset,int Method)
return false;
#else
LastWrite=false;
-#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE) && !defined(__VMS)
+#ifdef FILE_USE_OPEN
+ if (lseek64(hFile,Offset,Method)==-1)
+ return false;
+#elif defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE) && !defined(__VMS)
if (fseeko(hFile,Offset,Method)!=0)
+ return false;
#else
if (fseek(hFile,(long)Offset,Method)!=0)
-#endif
return false;
#endif
+#endif
return true;
}
@@ -467,7 +500,9 @@ int64 File::Tell()
return -1;
return INT32TO64(HighDist,LowDist);
#else
-#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
+#ifdef FILE_USE_OPEN
+ return lseek64(hFile,0,SEEK_CUR);
+#elif defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
return ftello(hFile);
#else
return ftell(hFile);
@@ -489,7 +524,7 @@ void File::Prealloc(int64 Size)
#if defined(_UNIX) && defined(USE_FALLOCATE)
// fallocate is rather new call. Only latest kernels support it.
// So we are not using it by default yet.
- int fd = fileno(hFile);
+ int fd = GetFD(hFile);
if (fd >= 0)
fallocate(fd, 0, 0, Size);
#endif
@@ -585,7 +620,7 @@ void File::GetOpenFileTime(RarTime *ft)
#endif
#if defined(_UNIX) || defined(_EMX)
struct stat st;
- fstat(fileno(hFile),&st);
+ fstat(GetFD(),&st);
*ft=st.st_mtime;
#endif
}
@@ -607,7 +642,7 @@ bool File::IsDevice()
uint Type=GetFileType(hFile);
return Type==FILE_TYPE_CHAR || Type==FILE_TYPE_PIPE;
#else
- return isatty(fileno(hFile));
+ return isatty(GetFD());
#endif
}
diff --git a/src/thirdparty/unrar/file.hpp b/src/thirdparty/unrar/file.hpp
index c50295edd..7829aaeb0 100644
--- a/src/thirdparty/unrar/file.hpp
+++ b/src/thirdparty/unrar/file.hpp
@@ -1,17 +1,24 @@
#ifndef _RAR_FILE_
#define _RAR_FILE_
+#ifdef _ANDROID // Need lseek64 to handle >2 GB files in Android.
+#define FILE_USE_OPEN
+#endif
+
#ifdef _WIN_ALL
-typedef HANDLE FileHandle;
-#define BAD_HANDLE INVALID_HANDLE_VALUE
+ typedef HANDLE FileHandle;
+ #define BAD_HANDLE INVALID_HANDLE_VALUE
+#elif defined(FILE_USE_OPEN)
+ typedef off_t FileHandle;
+ #define BAD_HANDLE -1
#else
-typedef FILE* FileHandle;
-#define BAD_HANDLE NULL
+ typedef FILE* FileHandle;
+ #define BAD_HANDLE NULL
#endif
class RAROptions;
-enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR};
+enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD};
enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR};
@@ -61,14 +68,13 @@ class File
File();
virtual ~File();
void operator = (File &SrcFile);
- bool Open(const wchar *Name,uint Mode=FMF_READ);
+ virtual bool Open(const wchar *Name,uint Mode=FMF_READ);
void TOpen(const wchar *Name);
bool WOpen(const wchar *Name);
bool Create(const wchar *Name,uint Mode=FMF_UPDATE|FMF_SHAREREAD);
void TCreate(const wchar *Name,uint Mode=FMF_UPDATE|FMF_SHAREREAD);
bool WCreate(const wchar *Name,uint Mode=FMF_UPDATE|FMF_SHAREREAD);
bool Close();
- void Flush();
bool Delete();
bool Rename(const wchar *NewName);
void Write(const void *Data,size_t Size);
@@ -85,7 +91,7 @@ class File
void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL);
static void SetCloseFileTimeByName(const wchar *Name,RarTime *ftm,RarTime *fta);
void GetOpenFileTime(RarTime *ft);
- bool IsOpened() {return(hFile!=BAD_HANDLE);};
+ bool IsOpened() {return hFile!=BAD_HANDLE;};
int64 FileLength();
void SetHandleType(FILE_HANDLETYPE Type) {HandleType=Type;}
FILE_HANDLETYPE GetHandleType() {return HandleType;}
@@ -100,6 +106,16 @@ class File
#ifdef _WIN_ALL
void RemoveSequentialFlag() {NoSequentialRead=true;}
#endif
+#ifdef _UNIX
+ int GetFD()
+ {
+#ifdef FILE_USE_OPEN
+ return hFile;
+#else
+ return fileno(hFile);
+#endif
+ }
+#endif
};
#endif
diff --git a/src/thirdparty/unrar/filefn.cpp b/src/thirdparty/unrar/filefn.cpp
index 2654fee6a..679060578 100644
--- a/src/thirdparty/unrar/filefn.cpp
+++ b/src/thirdparty/unrar/filefn.cpp
@@ -312,13 +312,12 @@ void CalcFileSum(File *SrcFile,uint *CRC32,byte *Blake2,uint Threads,int64 Size,
SaveFilePos SavePos(*SrcFile);
#ifndef SILENT
int64 FileLength=SrcFile->FileLength();
- if ((Flags & (CALCFSUM_SHOWTEXT|CALCFSUM_SHOWALL))!=0)
- {
- mprintf(St(MCalcCRC));
- mprintf(L" ");
- }
+#endif
+#ifndef GUI
+ if ((Flags & (CALCFSUM_SHOWTEXT|CALCFSUM_SHOWALL))!=0)
#endif
+ uiMsg(UIEVENT_FILESUMSTART);
if ((Flags & CALCFSUM_CURPOS)==0)
SrcFile->Seek(0,SEEK_SET);
@@ -346,8 +345,10 @@ void CalcFileSum(File *SrcFile,uint *CRC32,byte *Blake2,uint Threads,int64 Size,
if ((++BlockCount & 0xf)==0)
{
#ifndef SILENT
+#ifndef GUI
if ((Flags & CALCFSUM_SHOWALL)!=0)
- mprintf(L"\b\b\b\b%3d%%",ToPercent(BlockCount*int64(BufSize),FileLength));
+#endif
+ uiMsg(UIEVENT_FILESUMPROGRESS,ToPercent(BlockCount*int64(BufSize),FileLength));
#endif
Wait();
}
@@ -360,10 +361,10 @@ void CalcFileSum(File *SrcFile,uint *CRC32,byte *Blake2,uint Threads,int64 Size,
if (Size!=INT64NDF)
Size-=ReadSize;
}
-#ifndef SILENT
+#ifndef GUI
if ((Flags & CALCFSUM_SHOWALL)!=0)
- mprintf(L"\b\b\b\b ");
#endif
+ uiMsg(UIEVENT_FILESUMEND);
if (CRC32!=NULL)
*CRC32=HashCRC.GetCRC32();
diff --git a/src/thirdparty/unrar/find.cpp b/src/thirdparty/unrar/find.cpp
index ff9c58662..2e6c43481 100644
--- a/src/thirdparty/unrar/find.cpp
+++ b/src/thirdparty/unrar/find.cpp
@@ -70,7 +70,7 @@ bool FindFile::Next(FindData *fd,bool GetSymLink)
continue;
wchar Name[NM];
if (!CharToWide(ent->d_name,Name,ASIZE(Name)))
- Log(NULL,St(MInvalidName),Name);
+ uiMsg(UIERROR_INVALIDNAME,UINULL,Name);
if (CmpName(FindMask,Name,MATCH_NAMES))
{
@@ -79,16 +79,13 @@ bool FindFile::Next(FindData *fd,bool GetSymLink)
*PointToName(FullName)=0;
if (wcslen(FullName)+wcslen(Name)>=ASIZE(FullName)-1)
{
-#ifndef SILENT
- Log(NULL,L"\n%ls%ls",FullName,Name);
- Log(NULL,St(MPathTooLong));
-#endif
+ uiMsg(UIERROR_PATHTOOLONG,FullName,L"",Name);
return false;
}
wcscat(FullName,Name);
if (!FastFind(FullName,fd,GetSymLink))
{
- ErrHandler.OpenErrorMsg(NULL,FullName);
+ ErrHandler.OpenErrorMsg(FullName);
continue;
}
wcscpy(fd->Name,FullName);
diff --git a/src/thirdparty/unrar/hardlinks.cpp b/src/thirdparty/unrar/hardlinks.cpp
index a83fcd980..d13ad9ef7 100644
--- a/src/thirdparty/unrar/hardlinks.cpp
+++ b/src/thirdparty/unrar/hardlinks.cpp
@@ -10,7 +10,7 @@ bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
bool Success=CreateHardLink(NameNew,NameExisting,NULL)!=0;
if (!Success)
{
- Log(NULL,St(MErrCreateLnkH),NameNew);
+ uiMsg(UIERROR_HLINKCREATE,NameNew);
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_CREATE);
}
@@ -24,7 +24,7 @@ bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
bool Success=link(NameExistingA,NameNewA)==0;
if (!Success)
{
- Log(NULL,St(MErrCreateLnkH),NameNew);
+ uiMsg(UIERROR_HLINKCREATE,NameNew);
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_CREATE);
}
diff --git a/src/thirdparty/unrar/loclang.hpp b/src/thirdparty/unrar/loclang.hpp
index aa6b12f72..d07df1cef 100644
--- a/src/thirdparty/unrar/loclang.hpp
+++ b/src/thirdparty/unrar/loclang.hpp
@@ -1,388 +1,383 @@
-#define MYesNo "_Yes_No"
-#define MYesNoAll "_Yes_No_All"
-#define MYesNoAllQ "_Yes_No_All_nEver_Quit"
-#define MYesNoAllRenQ "_Yes_No_All_nEver_Rename_Quit"
-#define MContinueQuit "_Continue_Quit"
-#define MRetryAbort "_Retry_Abort"
-#define MCopyright "\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
-#define MRegTo "\nRegistered to %s\n"
-#define MShare "\nTrial version Type RAR -? for help\n"
-#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
-#define MBeta "beta"
-#define MMonthJan "Jan"
-#define MMonthFeb "Feb"
-#define MMonthMar "Mar"
-#define MMonthApr "Apr"
-#define MMonthMay "May"
-#define MMonthJun "Jun"
-#define MMonthJul "Jul"
-#define MMonthAug "Aug"
-#define MMonthSep "Sep"
-#define MMonthOct "Oct"
-#define MMonthNov "Nov"
-#define MMonthDec "Dec"
-#define MRARTitle1 "\nUsage: rar <command> -<switch 1> -<switch N> <archive> <files...>"
-#define MUNRARTitle1 "\nUsage: unrar <command> -<switch 1> -<switch N> <archive> <files...>"
-#define MRARTitle2 "\n <@listfiles...> <path_to_extract\\>"
-#define MCHelpCmd "\n\n<Commands>"
-#define MCHelpCmdA "\n a Add files to archive"
-#define MCHelpCmdC "\n c Add archive comment"
-#define MCHelpCmdCH "\n ch Change archive parameters"
-#define MCHelpCmdCW "\n cw Write archive comment to file"
-#define MCHelpCmdD "\n d Delete files from archive"
-#define MCHelpCmdE "\n e Extract files without archived paths"
-#define MCHelpCmdF "\n f Freshen files in archive"
-#define MCHelpCmdI "\n i[par]=<str> Find string in archives"
-#define MCHelpCmdK "\n k Lock archive"
-#define MCHelpCmdL "\n l[t[a],b] List archive contents [technical[all], bare]"
-#define MCHelpCmdM "\n m[f] Move to archive [files only]"
-#define MCHelpCmdP "\n p Print file to stdout"
-#define MCHelpCmdR "\n r Repair archive"
-#define MCHelpCmdRC "\n rc Reconstruct missing volumes"
-#define MCHelpCmdRN "\n rn Rename archived files"
-#define MCHelpCmdRR "\n rr[N] Add data recovery record"
-#define MCHelpCmdRV "\n rv[N] Create recovery volumes"
-#define MCHelpCmdS "\n s[name|-] Convert archive to or from SFX"
-#define MCHelpCmdT "\n t Test archive files"
-#define MCHelpCmdU "\n u Update files in archive"
-#define MCHelpCmdV "\n v[t[a],b] Verbosely list archive contents [technical[all],bare]"
-#define MCHelpCmdX "\n x Extract files with full path"
-#define MCHelpSw "\n\n<Switches>"
-#define MCHelpSwm "\n - Stop switches scanning"
-#define MCHelpSwAT "\n @[+] Disable [enable] file lists"
-#define MCHelpSwAC "\n ac Clear Archive attribute after compression or extraction"
-#define MCHelpSwAD "\n ad Append archive name to destination path"
-#define MCHelpSwAG "\n ag[format] Generate archive name using the current date"
-#define MCHelpSwAI "\n ai Ignore file attributes"
-#define MCHelpSwAO "\n ao Add files with Archive attribute set"
-#define MCHelpSwAP "\n ap<path> Set path inside archive"
-#define MCHelpSwAS "\n as Synchronize archive contents"
-#define MCHelpSwCm "\n c- Disable comments show"
-#define MCHelpSwCFGm "\n cfg- Disable read configuration"
-#define MCHelpSwCL "\n cl Convert names to lower case"
-#define MCHelpSwCU "\n cu Convert names to upper case"
-#define MCHelpSwDF "\n df Delete files after archiving"
-#define MCHelpSwDH "\n dh Open shared files"
-#define MCHelpSwDR "\n dr Delete files to Recycle Bin"
-#define MCHelpSwDS "\n ds Disable name sort for solid archive"
-#define MCHelpSwDW "\n dw Wipe files after archiving"
-#define MCHelpSwEa "\n e[+]<attr> Set file exclude and include attributes"
-#define MCHelpSwED "\n ed Do not add empty directories"
-#define MCHelpSwEE "\n ee Do not save and extract extended attributes"
-#define MCHelpSwEN "\n en Do not put 'end of archive' block"
-#define MCHelpSwEP "\n ep Exclude paths from names"
-#define MCHelpSwEP1 "\n ep1 Exclude base directory from names"
-#define MCHelpSwEP2 "\n ep2 Expand paths to full"
-#define MCHelpSwEP3 "\n ep3 Expand paths to full including the drive letter"
-#define MCHelpSwF "\n f Freshen files"
-#define MCHelpSwHP "\n hp[password] Encrypt both file data and headers"
-#define MCHelpSwHT "\n ht[b|c] Select hash type [BLAKE2,CRC32] for file checksum"
-#define MCHelpSwIDP "\n id[c,d,p,q] Disable messages"
-#define MCHelpSwIEML "\n ieml[addr] Send archive by email"
-#define MCHelpSwIERR "\n ierr Send all messages to stderr"
-#define MCHelpSwILOG "\n ilog[name] Log errors to file (registered versions only)"
-#define MCHelpSwINUL "\n inul Disable all messages"
-#define MCHelpSwIOFF "\n ioff Turn PC off after completing an operation"
-#define MCHelpSwISND "\n isnd Enable sound"
-#define MCHelpSwK "\n k Lock archive"
-#define MCHelpSwKB "\n kb Keep broken extracted files"
-#define MCHelpSwLog "\n log[f][=name] Write names to log file"
-#define MCHelpSwMn "\n m<0..5> Set compression level (0-store...3-default...5-maximal)"
-#define MCHelpSwMA "\n ma[4|5] Specify a version of archiving format"
-#define MCHelpSwMC "\n mc<par> Set advanced compression parameters"
-#define MCHelpSwMD "\n md<n>[k,m,g] Dictionary size in KB, MB or GB"
-#define MCHelpSwMS "\n ms[ext;ext] Specify file types to store"
-#define MCHelpSwMT "\n mt<threads> Set the number of threads"
-#define MCHelpSwN "\n n<file> Additionally filter included files"
-#define MCHelpSwNa "\n n@ Read additional filter masks from stdin"
-#define MCHelpSwNal "\n n@<list> Read additional filter masks from list file"
-#define MCHelpSwO "\n o[+|-] Set the overwrite mode"
-#define MCHelpSwOC "\n oc Set NTFS Compressed attribute"
-#define MCHelpSwOH "\n oh Save hard links as the link instead of the file"
-#define MCHelpSwOI "\n oi[0-4][:min] Save identical files as references"
-#define MCHelpSwOL "\n ol Save symbolic links as the link instead of the file"
-#define MCHelpSwOR "\n or Rename files automatically"
-#define MCHelpSwOS "\n os Save NTFS streams"
-#define MCHelpSwOW "\n ow Save or restore file owner and group"
-#define MCHelpSwP "\n p[password] Set password"
-#define MCHelpSwPm "\n p- Do not query password"
-#define MCHelpSwQO "\n qo[-|+] Add quick open information [none|force]"
-#define MCHelpSwR "\n r Recurse subdirectories"
-#define MCHelpSwRm "\n r- Disable recursion"
-#define MCHelpSwR0 "\n r0 Recurse subdirectories for wildcard names only"
-#define MCHelpSwRI "\n ri<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms"
-#define MCHelpSwRR "\n rr[N] Add data recovery record"
-#define MCHelpSwRV "\n rv[N] Create recovery volumes"
-#define MCHelpSwS "\n s[<N>,v[-],e] Create solid archive"
-#define MCHelpSwSm "\n s- Disable solid archiving"
-#define MCHelpSwSC "\n sc<chr>[obj] Specify the character set"
-#define MCHelpSwSFX "\n sfx[name] Create SFX archive"
-#define MCHelpSwSI "\n si[name] Read data from standard input (stdin)"
-#define MCHelpSwSL "\n sl<size> Process files with size less than specified"
-#define MCHelpSwSM "\n sm<size> Process files with size more than specified"
-#define MCHelpSwT "\n t Test files after archiving"
-#define MCHelpSwTK "\n tk Keep original archive time"
-#define MCHelpSwTL "\n tl Set archive time to latest file"
-#define MCHelpSwTN "\n tn<time> Process files newer than <time>"
-#define MCHelpSwTO "\n to<time> Process files older than <time>"
-#define MCHelpSwTA "\n ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format"
-#define MCHelpSwTB "\n tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format"
-#define MCHelpSwTS "\n ts<m,c,a>[N] Save or restore file time (modification, creation, access)"
-#define MCHelpSwU "\n u Update files"
-#define MCHelpSwV "\n v Create volumes with size autodetection or list all volumes"
-#define MCHelpSwVUnr "\n v List all volumes"
-#define MCHelpSwVn "\n v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1]"
-#define MCHelpSwVD "\n vd Erase disk contents before creating volume"
-#define MCHelpSwVER "\n ver[n] File version control"
-#define MCHelpSwVN "\n vn Use the old style volume naming scheme"
-#define MCHelpSwVP "\n vp Pause before each volume"
-#define MCHelpSwW "\n w<path> Assign work directory"
-#define MCHelpSwX "\n x<file> Exclude specified file"
-#define MCHelpSwXa "\n x@ Read file names to exclude from stdin"
-#define MCHelpSwXal "\n x@<list> Exclude files listed in specified list file"
-#define MCHelpSwY "\n y Assume Yes on all queries"
-#define MCHelpSwZ "\n z[file] Read archive comment from file"
-#define MBadArc "\nERROR: Bad archive %s\n"
-#define MAskPsw "Enter password (will not be echoed)"
-#define MAskPswFor "\nEnter password (will not be echoed) for %s: "
-#define MReAskPsw "\nReenter password: "
-#define MNotMatchPsw "\nERROR: Passwords do not match\n"
-#define MErrWrite "Write error in the file %s"
-#define MErrRead "Read error in the file %s"
-#define MErrSeek "Seek error in the file %s"
-#define MErrFClose "Cannot close the file %s"
-#define MErrOutMem "Not enough memory"
-#define MErrBrokenArc "Corrupt archive - use 'Repair' command"
-#define MProgAborted "Program aborted"
-#define MErrRename "\nCannot rename %s to %s"
-#define MAbsNextVol "\nCannot find volume %s"
-#define MBreak "\nUser break\n"
-#define MAskCreatVol "\nCreate next volume ?"
-#define MAskNextDisk "\nDisk full. Insert next"
-#define MCreatVol "\n\nCreating %sarchive %s\n"
-#define MAskNextVol "\nInsert disk with %s"
-#define MTestVol "\n\nTesting archive %s\n"
-#define MExtrVol "\n\nExtracting from %s\n"
-#define MConverting "\nConverting %s"
-#define MCvtToSFX "\nConvert archives to SFX"
-#define MCvtFromSFX "\nRemoving SFX module"
-#define MNotSFX "\n%s is not SFX archive"
-#define MNotRAR "\n%s is not RAR archive"
-#define MNotFirstVol "\n%s is not the first volume"
-#define MCvtOldFormat "\n%s - cannot convert to SFX archive with old format"
-#define MCannotCreate "\nCannot create %s"
-#define MCannotOpen "\nCannot open %s"
-#define MUnknownMeth "\nUnknown method in %s"
-#define MVerRequired "\nYou need RAR %d.%d to unpack it"
-#define MNewRarFormat "\nUnsupported archive format. Please update RAR to a newer version."
-#define MOk " OK"
-#define MDone "\nDone"
-#define MLockingArc "\nLocking archive"
-#define MNotMdfOld "\n\nERROR: Cannot modify old format archive"
-#define MNotMdfLock "\n\nERROR: Locked archive"
-#define MNotMdfVol "\n\nERROR: Cannot modify volume"
-#define MPackAskReg "\nEvaluation copy. Please register.\n"
-#define MCreateArchive "\nCreating %sarchive %s\n"
-#define MUpdateArchive "\nUpdating %sarchive %s\n"
-#define MAddSolid "solid "
-#define MAddFile "\nAdding %-58s "
-#define MUpdFile "\nUpdating %-58s "
-#define MAddPoints "\n... %-58s "
-#define MCannotUpdPswSolid "\nERROR: Cannot update solid archives with password\n"
-#define MMoveDelFiles "\n\nDeleting files %s..."
-#define MMoveDelDirs "and directories"
-#define MMoveDelFile "\nDeleting %-30s"
-#define MMoveDeleted " deleted"
-#define MMoveNotDeleted " NOT DELETED"
-#define MClearAttrib "\n\nClearing attributes..."
-#define MMoveDelDir "\nDeleting directory %-30s"
-#define MWarErrFOpen "\nWARNING: Cannot open %d %s"
-#define MErrOpenFiles "files"
-#define MErrOpenFile "file"
-#define MAddNoFiles "\nWARNING: No files"
-#define MMdfEncrSol "\n%s: encrypted"
-#define MCannotMdfEncrSol "\nCannot modify solid archive containing encrypted files"
-#define MAddAnalyze "\nAnalyzing archived files: "
-#define MRepacking "\nRepacking archived files: "
-#define MCRCFailed "\n%-20s - checksum error"
-#define MExtrTest "\n\nTesting archive %s\n"
-#define MExtracting "\n\nExtracting from %s\n"
-#define MUseCurPsw "\n%s - use current password ?"
-#define MCreatDir "\nCreating %-56s"
-#define MExtrSkipFile "\nSkipping %-56s"
-#define MExtrTestFile "\nTesting %-56s"
-#define MExtrFile "\nExtracting %-56s"
-#define MExtrPoints "\n... %-56s"
-#define MExtrErrMkDir "\nCannot create directory %s"
-#define MExtrPrinting "\n------ Printing %s\n\n"
-#define MEncrBadCRC "\nChecksum error in the encrypted file %s. Corrupt file or wrong password."
-#define MExtrNoFiles "\nNo files to extract"
-#define MExtrAllOk "\nAll OK"
-#define MExtrTotalErr "\nTotal errors: %ld"
-#define MFileExists "\n\n%s already exists. Overwrite it ?"
-#define MAskOverwrite "\nOverwrite %s ?"
-#define MAskNewName "\nEnter new name: "
-#define MHeaderBroken "\nCorrupt header is found"
-#define MMainHeaderBroken "\nMain archive header is corrupt"
-#define MLogFileHead "\n%s - the file header is corrupt"
-#define MLogCommHead "\nThe comment header is corrupt\n"
-#define MLogProtectHead "The data recovery header is corrupt"
-#define MReadStdinCmt "\nReading comment from stdin\n"
-#define MReadCommFrom "\nReading comment from %s"
-#define MDelComment "\nDeleting comment from %s"
-#define MAddComment "\nAdding comment to %s"
-#define MFCommAdd "\nAdding file comments"
-#define MAskFComm "\n\nReading comment for %s : %s from stdin\n"
-#define MLogCommBrk "\nThe archive comment is corrupt"
-#define MCommAskCont "\nPress 'Enter' to continue or 'Q' to quit:"
-#define MWriteCommTo "\nWrite comment to %s"
-#define MCommNotPres "\nComment is not present"
-#define MDelFrom "\nDeleting from %s"
-#define MDeleting "\nDeleting %s"
-#define MEraseArc "\nErasing empty archive %s"
-#define MNoDelFiles "\nNo files to delete"
-#define MLogTitle "\n\n-------- %2d %s %d, archive %s\n"
-#define MPathTooLong "\nERROR: Path too long\n"
-#define MListArchive "Archive"
-#define MListDetails "Details"
-#define MListSolid "solid"
-#define MListSFX "SFX"
-#define MListVolume "volume"
-#define MListRR "recovery record"
-#define MListLock "lock"
-#define MListEnc "encrypted"
-#define MListEncHead "encrypted headers"
-#define MListTitleL " Attributes Size Date Time Name"
-#define MListTitleV " Attributes Size Packed Ratio Date Time Checksum Name"
-#define MListName "Name"
-#define MListType "Type"
-#define MListFile "File"
-#define MListDir "Directory"
-#define MListUSymlink "Unix symbolic link"
-#define MListWSymlink "Windows symbolic link"
-#define MListJunction "NTFS junction point"
-#define MListHardlink "Hard link"
-#define MListCopy "File copy"
-#define MListStream "NTFS alternate data stream"
-#define MListTarget "Target"
-#define MListSize "Size"
-#define MListPacked "Packed size"
-#define MListRatio "Ratio"
-#define MListMtime "mtime"
-#define MListCtime "ctime"
-#define MListAtime "atime"
-#define MListAttr "Attributes"
-#define MListFlags "Flags"
-#define MListCompInfo "Compression"
-#define MListHostOS "Host OS"
-#define MListFileVer "File version"
-#define MListService "Service"
-#define MListEAHead "\n OS/2 extended attributes"
-#define MListUOHead "\n Unix Owner/Group data: %-14s %-14s"
-#define MListBeEAHead "\n BeOS extended attributes"
-#define MListNTACLHead "\n NTFS security data"
-#define MListStrmHead "\n NTFS stream: %s"
-#define MListUnkHead "\n Unknown subheader type: 0x%04x"
-#define MFileComment "\nComment: "
-#define MYes "Yes"
-#define MNo "No"
-#define MListNoFiles " 0 files\n"
-#define MRprReconstr "\nReconstructing %s"
-#define MRprBuild "\nBuilding %s"
-#define MRprOldFormat "\nCannot repair archive with old format"
-#define MRprFind "\nFound %s"
-#define MRprAskIsSol "\nThe archive header is corrupt. Mark archive as solid ?"
-#define MRprNoFiles "\nNo files found"
-#define MLogUnexpEOF "\nUnexpected end of archive"
-#define MRepAskReconst "\nReconstruct archive structure ?"
-#define MRecScanning "\nScanning..."
-#define MRecRNotFound "\nData recovery record not found"
-#define MRecRFound "\nData recovery record found"
-#define MRecSecDamage "\nSector %ld (offsets %lX...%lX) damaged"
-#define MRecCorrected " - data recovered"
-#define MRecFailed " - cannot recover data"
-#define MAddRecRec "\nAdding data recovery record"
-#define MEraseForVolume "\n\nErasing contents of drive %c:\n"
-#define MGetOwnersError "\nWARNING: Cannot get %s owner and group\n"
-#define MErrGetOwnerID "\nWARNING: Cannot get owner %s ID\n"
-#define MErrGetGroupID "\nWARNING: Cannot get group %s ID\n"
-#define MOwnersBroken "\nERROR: %s group and owner data are corrupt\n"
-#define MSetOwnersError "\nWARNING: Cannot set %s owner and group\n"
-#define MErrLnkRead "\nWARNING: Cannot read symbolic link %s"
-#define MSymLinkExists "\nWARNING: Symbolic link %s already exists"
-#define MAskRetryCreate "\nCannot create %s. Retry ?"
-#define MListMACHead1 "\n Mac OS file type: %c%c%c%c ; "
-#define MListMACHead2 "file creator: %c%c%c%c\n"
-#define MDataBadCRC "\n%-20s : packed data checksum error in volume %s"
-#define MFileRO "\n%s is read-only"
-#define MACLGetError "\nWARNING: Cannot get %s security data\n"
-#define MACLSetError "\nWARNING: Cannot set %s security data\n"
-#define MACLBroken "\nERROR: %s security data are corrupt\n"
-#define MACLUnknown "\nWARNING: Unknown format of %s security data\n"
-#define MStreamBroken "\nERROR: %s stream data are corrupt\n"
-#define MStreamUnknown "\nWARNING: Unknown format of %s stream data\n"
-#define MInvalidName "\nERROR: Invalid file name %s"
-#define MEABroken "\nERROR: %s extended attributes are corrupt\n"
-#define MEAUnknHeader "\nWARNING: %s - unknown format of extended attributes\n"
-#define MCannotSetEA "\nWARNING: cannot set extended attributes to %s\n"
-#define MCannotGetEA "\nERROR: Cannot get extended attributes of %s\n"
-#define MShowEA " (+EA)"
-#define MSkipEA "\n...skipping extended attributes"
-#define MProcessArc "\n\nProcessing archive %s"
-#define MSyncScanError "\nFile search errors, cannot synchronize archive"
-#define MCorrectingName "\nWARNING: Attempting to correct the invalid file name"
-#define MUnpCannotMerge "\nWARNING: You need to start extraction from a previous volume to unpack %s"
-#define MUnknownOption "\nERROR: Unknown option: %s"
-#define MSubHeadCorrupt "\nERROR: Corrupt data header found, ignored"
-#define MSubHeadUnknown "\nWARNING: Unknown data header format, ignored"
-#define MSubHeadDataCRC "\nERROR: Corrupt %s data block"
-#define MSubHeadType "\nData header type: %s"
-#define MScanError "\nCannot read contents of %s"
-#define MNotVolume "\n%s is not volume"
-#define MRecVolDiffSets "\nERROR: %s and %s belong to different sets"
-#define MRecVolMissing "\n%d volumes missing"
-#define MRecVolFound "\n%d recovery volumes found"
-#define MRecVolAllExist "\nNothing to reconstruct"
-#define MRecVolCannotFix "\nReconstruction impossible"
-#define MReconstructing "\nReconstructing..."
-#define MCreating "\nCreating %s"
-#define MRenaming "\nRenaming %s to %s"
-#define MNTFSRequired "\nWrite error: only NTFS file system supports files larger than 4 GB"
-#define MErrChangeAttr "\nWARNING: Cannot change attributes of %s"
-#define MWrongSFXVer "\nERROR: default SFX module does not support RAR %d.%d archives"
-#define MCannotEncName "\nCannot encrypt archive already contained encrypted files"
-#define MCannotEmail "\nCannot email the file %s"
-#define MCopyrightS "\nRAR SFX archive"
-#define MSHelpCmd "\n\n<Commands>"
-#define MSHelpCmdE "\n -x Extract from archive (default)"
-#define MSHelpCmdT "\n -t Test archive files"
-#define MSHelpCmdV "\n -v Verbosely list contents of archive"
-#define MMaxPathLimit "\nTotal path and file name length must not exceed %d characters"
-#define MRecVolLimit "\nTotal number of usual and recovery volumes must not exceed %d"
-#define MVolumeNumber "volume %d"
-#define MCannotDelete "\nCannot delete %s"
-#define MCalcCRC "\nCalculating the checksum"
-#define MTooLargeSFXArc "\nWARNING: Too large SFX archive. Windows cannot run the executable file exceeding 4 GB."
-#define MCalcCRCAllVol "\nCalculating checksums of all volumes."
-#define MNotEnoughDisk "\nERROR: Not enough disk space for %s."
-#define MNewerRAR "\nYou may need a newer version of RAR."
-#define MUnkEncMethod "\nUnknown encryption method in %s"
-#define MWrongPassword "\nThe specified password is incorrect."
-#define MRepairing "\nRepairing"
-#define MAreaDamaged "\nCorrupt %d bytes at %08x %08x"
-#define MBlocksRecovered "\n%d blocks recovered."
-#define MRRDamaged "\nRecovery record is corrupt."
-#define MTestingRR "\nTesting the recovery record"
-#define MFailed "Failed"
-#define MIncompatSwitch "\n%s switch is not supported for RAR %d.x archive format."
-#define MSearchDupFiles "\nSearching for identical files"
-#define MNumFound "%d found."
-#define MUnknownExtra "\nUnknown extra field in %s."
-#define MCopyError "\nCannot copy %s to %s."
-#define MCopyErrorHint "\nYou need to unpack the entire archive to create file copy entries."
-#define MCopyingData "\nCopying data"
-#define MErrCreateLnkS "\nCannot create symbolic link %s"
-#define MErrCreateLnkH "\nCannot create hard link %s"
-#define MNeedAdmin "\nYou may need to run RAR as administrator"
-#define MDictOutMem "\nNot enough memory for %d MB compression dictionary, changed to %d MB."
-#define MUseSmalllerDict "\nPlease use a smaller compression dictionary."
+#define MYesNo L"_Yes_No"
+#define MYesNoAll L"_Yes_No_All"
+#define MYesNoAllQ L"_Yes_No_All_nEver_Quit"
+#define MYesNoAllRenQ L"_Yes_No_All_nEver_Rename_Quit"
+#define MContinueQuit L"_Continue_Quit"
+#define MRetryAbort L"_Retry_Abort"
+#define MCopyright L"\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
+#define MRegTo L"\nRegistered to %s\n"
+#define MShare L"\nTrial version Type RAR -? for help\n"
+#define MUCopyright L"\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
+#define MBeta L"beta"
+#define MMonthJan L"Jan"
+#define MMonthFeb L"Feb"
+#define MMonthMar L"Mar"
+#define MMonthApr L"Apr"
+#define MMonthMay L"May"
+#define MMonthJun L"Jun"
+#define MMonthJul L"Jul"
+#define MMonthAug L"Aug"
+#define MMonthSep L"Sep"
+#define MMonthOct L"Oct"
+#define MMonthNov L"Nov"
+#define MMonthDec L"Dec"
+#define MRARTitle1 L"\nUsage: rar <command> -<switch 1> -<switch N> <archive> <files...>"
+#define MUNRARTitle1 L"\nUsage: unrar <command> -<switch 1> -<switch N> <archive> <files...>"
+#define MRARTitle2 L"\n <@listfiles...> <path_to_extract\\>"
+#define MCHelpCmd L"\n\n<Commands>"
+#define MCHelpCmdA L"\n a Add files to archive"
+#define MCHelpCmdC L"\n c Add archive comment"
+#define MCHelpCmdCH L"\n ch Change archive parameters"
+#define MCHelpCmdCW L"\n cw Write archive comment to file"
+#define MCHelpCmdD L"\n d Delete files from archive"
+#define MCHelpCmdE L"\n e Extract files without archived paths"
+#define MCHelpCmdF L"\n f Freshen files in archive"
+#define MCHelpCmdI L"\n i[par]=<str> Find string in archives"
+#define MCHelpCmdK L"\n k Lock archive"
+#define MCHelpCmdL L"\n l[t[a],b] List archive contents [technical[all], bare]"
+#define MCHelpCmdM L"\n m[f] Move to archive [files only]"
+#define MCHelpCmdP L"\n p Print file to stdout"
+#define MCHelpCmdR L"\n r Repair archive"
+#define MCHelpCmdRC L"\n rc Reconstruct missing volumes"
+#define MCHelpCmdRN L"\n rn Rename archived files"
+#define MCHelpCmdRR L"\n rr[N] Add data recovery record"
+#define MCHelpCmdRV L"\n rv[N] Create recovery volumes"
+#define MCHelpCmdS L"\n s[name|-] Convert archive to or from SFX"
+#define MCHelpCmdT L"\n t Test archive files"
+#define MCHelpCmdU L"\n u Update files in archive"
+#define MCHelpCmdV L"\n v[t[a],b] Verbosely list archive contents [technical[all],bare]"
+#define MCHelpCmdX L"\n x Extract files with full path"
+#define MCHelpSw L"\n\n<Switches>"
+#define MCHelpSwm L"\n - Stop switches scanning"
+#define MCHelpSwAT L"\n @[+] Disable [enable] file lists"
+#define MCHelpSwAC L"\n ac Clear Archive attribute after compression or extraction"
+#define MCHelpSwAD L"\n ad Append archive name to destination path"
+#define MCHelpSwAG L"\n ag[format] Generate archive name using the current date"
+#define MCHelpSwAI L"\n ai Ignore file attributes"
+#define MCHelpSwAO L"\n ao Add files with Archive attribute set"
+#define MCHelpSwAP L"\n ap<path> Set path inside archive"
+#define MCHelpSwAS L"\n as Synchronize archive contents"
+#define MCHelpSwCm L"\n c- Disable comments show"
+#define MCHelpSwCFGm L"\n cfg- Disable read configuration"
+#define MCHelpSwCL L"\n cl Convert names to lower case"
+#define MCHelpSwCU L"\n cu Convert names to upper case"
+#define MCHelpSwDF L"\n df Delete files after archiving"
+#define MCHelpSwDH L"\n dh Open shared files"
+#define MCHelpSwDR L"\n dr Delete files to Recycle Bin"
+#define MCHelpSwDS L"\n ds Disable name sort for solid archive"
+#define MCHelpSwDW L"\n dw Wipe files after archiving"
+#define MCHelpSwEa L"\n e[+]<attr> Set file exclude and include attributes"
+#define MCHelpSwED L"\n ed Do not add empty directories"
+#define MCHelpSwEN L"\n en Do not put 'end of archive' block"
+#define MCHelpSwEP L"\n ep Exclude paths from names"
+#define MCHelpSwEP1 L"\n ep1 Exclude base directory from names"
+#define MCHelpSwEP2 L"\n ep2 Expand paths to full"
+#define MCHelpSwEP3 L"\n ep3 Expand paths to full including the drive letter"
+#define MCHelpSwF L"\n f Freshen files"
+#define MCHelpSwHP L"\n hp[password] Encrypt both file data and headers"
+#define MCHelpSwHT L"\n ht[b|c] Select hash type [BLAKE2,CRC32] for file checksum"
+#define MCHelpSwIDP L"\n id[c,d,p,q] Disable messages"
+#define MCHelpSwIEML L"\n ieml[addr] Send archive by email"
+#define MCHelpSwIERR L"\n ierr Send all messages to stderr"
+#define MCHelpSwILOG L"\n ilog[name] Log errors to file (registered versions only)"
+#define MCHelpSwINUL L"\n inul Disable all messages"
+#define MCHelpSwIOFF L"\n ioff Turn PC off after completing an operation"
+#define MCHelpSwISND L"\n isnd Enable sound"
+#define MCHelpSwK L"\n k Lock archive"
+#define MCHelpSwKB L"\n kb Keep broken extracted files"
+#define MCHelpSwLog L"\n log[f][=name] Write names to log file"
+#define MCHelpSwMn L"\n m<0..5> Set compression level (0-store...3-default...5-maximal)"
+#define MCHelpSwMA L"\n ma[4|5] Specify a version of archiving format"
+#define MCHelpSwMC L"\n mc<par> Set advanced compression parameters"
+#define MCHelpSwMD L"\n md<n>[k,m,g] Dictionary size in KB, MB or GB"
+#define MCHelpSwMS L"\n ms[ext;ext] Specify file types to store"
+#define MCHelpSwMT L"\n mt<threads> Set the number of threads"
+#define MCHelpSwN L"\n n<file> Additionally filter included files"
+#define MCHelpSwNa L"\n n@ Read additional filter masks from stdin"
+#define MCHelpSwNal L"\n n@<list> Read additional filter masks from list file"
+#define MCHelpSwO L"\n o[+|-] Set the overwrite mode"
+#define MCHelpSwOC L"\n oc Set NTFS Compressed attribute"
+#define MCHelpSwOH L"\n oh Save hard links as the link instead of the file"
+#define MCHelpSwOI L"\n oi[0-4][:min] Save identical files as references"
+#define MCHelpSwOL L"\n ol Save symbolic links as the link instead of the file"
+#define MCHelpSwOR L"\n or Rename files automatically"
+#define MCHelpSwOS L"\n os Save NTFS streams"
+#define MCHelpSwOW L"\n ow Save or restore file owner and group"
+#define MCHelpSwP L"\n p[password] Set password"
+#define MCHelpSwPm L"\n p- Do not query password"
+#define MCHelpSwQO L"\n qo[-|+] Add quick open information [none|force]"
+#define MCHelpSwR L"\n r Recurse subdirectories"
+#define MCHelpSwRm L"\n r- Disable recursion"
+#define MCHelpSwR0 L"\n r0 Recurse subdirectories for wildcard names only"
+#define MCHelpSwRI L"\n ri<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms"
+#define MCHelpSwRR L"\n rr[N] Add data recovery record"
+#define MCHelpSwRV L"\n rv[N] Create recovery volumes"
+#define MCHelpSwS L"\n s[<N>,v[-],e] Create solid archive"
+#define MCHelpSwSm L"\n s- Disable solid archiving"
+#define MCHelpSwSC L"\n sc<chr>[obj] Specify the character set"
+#define MCHelpSwSFX L"\n sfx[name] Create SFX archive"
+#define MCHelpSwSI L"\n si[name] Read data from standard input (stdin)"
+#define MCHelpSwSL L"\n sl<size> Process files with size less than specified"
+#define MCHelpSwSM L"\n sm<size> Process files with size more than specified"
+#define MCHelpSwT L"\n t Test files after archiving"
+#define MCHelpSwTK L"\n tk Keep original archive time"
+#define MCHelpSwTL L"\n tl Set archive time to latest file"
+#define MCHelpSwTN L"\n tn<time> Process files newer than <time>"
+#define MCHelpSwTO L"\n to<time> Process files older than <time>"
+#define MCHelpSwTA L"\n ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format"
+#define MCHelpSwTB L"\n tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format"
+#define MCHelpSwTS L"\n ts<m,c,a>[N] Save or restore file time (modification, creation, access)"
+#define MCHelpSwU L"\n u Update files"
+#define MCHelpSwV L"\n v Create volumes with size autodetection or list all volumes"
+#define MCHelpSwVUnr L"\n v List all volumes"
+#define MCHelpSwVn L"\n v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1]"
+#define MCHelpSwVD L"\n vd Erase disk contents before creating volume"
+#define MCHelpSwVER L"\n ver[n] File version control"
+#define MCHelpSwVN L"\n vn Use the old style volume naming scheme"
+#define MCHelpSwVP L"\n vp Pause before each volume"
+#define MCHelpSwW L"\n w<path> Assign work directory"
+#define MCHelpSwX L"\n x<file> Exclude specified file"
+#define MCHelpSwXa L"\n x@ Read file names to exclude from stdin"
+#define MCHelpSwXal L"\n x@<list> Exclude files listed in specified list file"
+#define MCHelpSwY L"\n y Assume Yes on all queries"
+#define MCHelpSwZ L"\n z[file] Read archive comment from file"
+#define MBadArc L"\nERROR: Bad archive %s\n"
+#define MAskPsw L"Enter password (will not be echoed)"
+#define MAskPswFor L"\nEnter password (will not be echoed) for %s: "
+#define MReAskPsw L"\nReenter password: "
+#define MNotMatchPsw L"\nERROR: Passwords do not match\n"
+#define MErrWrite L"Write error in the file %s"
+#define MErrRead L"Read error in the file %s"
+#define MErrSeek L"Seek error in the file %s"
+#define MErrFClose L"Cannot close the file %s"
+#define MErrOutMem L"Not enough memory"
+#define MErrBrokenArc L"Corrupt archive - use 'Repair' command"
+#define MProgAborted L"Program aborted"
+#define MErrRename L"\nCannot rename %s to %s"
+#define MAbsNextVol L"\nCannot find volume %s"
+#define MBreak L"\nUser break\n"
+#define MAskCreatVol L"\nCreate next volume ?"
+#define MAskNextDisk L"\nDisk full. Insert next"
+#define MCreatVol L"\n\nCreating %sarchive %s\n"
+#define MAskNextVol L"\nInsert disk with %s"
+#define MTestVol L"\n\nTesting archive %s\n"
+#define MExtrVol L"\n\nExtracting from %s\n"
+#define MConverting L"\nConverting %s"
+#define MCvtToSFX L"\nConvert archives to SFX"
+#define MCvtFromSFX L"\nRemoving SFX module"
+#define MNotSFX L"\n%s is not SFX archive"
+#define MNotRAR L"\n%s is not RAR archive"
+#define MNotFirstVol L"\n%s is not the first volume"
+#define MCvtOldFormat L"\n%s - cannot convert to SFX archive with old format"
+#define MCannotCreate L"\nCannot create %s"
+#define MCannotOpen L"\nCannot open %s"
+#define MUnknownMeth L"\nUnknown method in %s"
+#define MNewRarFormat L"\nUnsupported archive format. Please update RAR to a newer version."
+#define MOk L" OK"
+#define MDone L"\nDone"
+#define MLockingArc L"\nLocking archive"
+#define MNotMdfOld L"\n\nERROR: Cannot modify old format archive"
+#define MNotMdfLock L"\n\nERROR: Locked archive"
+#define MNotMdfVol L"\n\nERROR: Cannot modify volume"
+#define MPackAskReg L"\nEvaluation copy. Please register.\n"
+#define MCreateArchive L"\nCreating %sarchive %s\n"
+#define MUpdateArchive L"\nUpdating %sarchive %s\n"
+#define MAddSolid L"solid "
+#define MAddFile L"\nAdding %-58s "
+#define MUpdFile L"\nUpdating %-58s "
+#define MAddPoints L"\n... %-58s "
+#define MMoveDelFiles L"\n\nDeleting files %s..."
+#define MMoveDelDirs L"and directories"
+#define MMoveDelFile L"\nDeleting %-30s"
+#define MMoveDeleted L" deleted"
+#define MMoveNotDeleted L" NOT DELETED"
+#define MClearAttrib L"\n\nClearing attributes..."
+#define MMoveDelDir L"\nDeleting directory %-30s"
+#define MWarErrFOpen L"\nWARNING: Cannot open %d %s"
+#define MErrOpenFiles L"files"
+#define MErrOpenFile L"file"
+#define MAddNoFiles L"\nWARNING: No files"
+#define MMdfEncrSol L"\n%s: encrypted"
+#define MCannotMdfEncrSol L"\nCannot modify solid archive containing encrypted files"
+#define MAddAnalyze L"\nAnalyzing archived files: "
+#define MRepacking L"\nRepacking archived files: "
+#define MCRCFailed L"\n%-20s - checksum error"
+#define MExtrTest L"\n\nTesting archive %s\n"
+#define MExtracting L"\n\nExtracting from %s\n"
+#define MUseCurPsw L"\n%s - use current password ?"
+#define MCreatDir L"\nCreating %-56s"
+#define MExtrSkipFile L"\nSkipping %-56s"
+#define MExtrTestFile L"\nTesting %-56s"
+#define MExtrFile L"\nExtracting %-56s"
+#define MExtrPoints L"\n... %-56s"
+#define MExtrErrMkDir L"\nCannot create directory %s"
+#define MExtrPrinting L"\n------ Printing %s\n\n"
+#define MEncrBadCRC L"\nChecksum error in the encrypted file %s. Corrupt file or wrong password."
+#define MExtrNoFiles L"\nNo files to extract"
+#define MExtrAllOk L"\nAll OK"
+#define MExtrTotalErr L"\nTotal errors: %ld"
+#define MFileExists L"\n\n%s already exists. Overwrite it ?"
+#define MAskOverwrite L"\nOverwrite %s ?"
+#define MAskNewName L"\nEnter new name: "
+#define MHeaderBroken L"\nCorrupt header is found"
+#define MMainHeaderBroken L"\nMain archive header is corrupt"
+#define MLogFileHead L"\n%s - the file header is corrupt"
+#define MLogProtectHead L"The data recovery header is corrupt"
+#define MReadStdinCmt L"\nReading comment from stdin\n"
+#define MReadCommFrom L"\nReading comment from %s"
+#define MDelComment L"\nDeleting comment from %s"
+#define MAddComment L"\nAdding comment to %s"
+#define MFCommAdd L"\nAdding file comments"
+#define MAskFComm L"\n\nReading comment for %s : %s from stdin\n"
+#define MLogCommBrk L"\nThe archive comment is corrupt"
+#define MCommAskCont L"\nPress 'Enter' to continue or 'Q' to quit:"
+#define MWriteCommTo L"\nWrite comment to %s"
+#define MCommNotPres L"\nComment is not present"
+#define MDelFrom L"\nDeleting from %s"
+#define MDeleting L"\nDeleting %s"
+#define MEraseArc L"\nErasing empty archive %s"
+#define MNoDelFiles L"\nNo files to delete"
+#define MLogTitle L"\n\n-------- %2d %s %d, archive %s\n"
+#define MPathTooLong L"\nERROR: Path too long\n"
+#define MListArchive L"Archive"
+#define MListDetails L"Details"
+#define MListSolid L"solid"
+#define MListSFX L"SFX"
+#define MListVolume L"volume"
+#define MListRR L"recovery record"
+#define MListLock L"lock"
+#define MListEnc L"encrypted"
+#define MListEncHead L"encrypted headers"
+#define MListTitleL L" Attributes Size Date Time Name"
+#define MListTitleV L" Attributes Size Packed Ratio Date Time Checksum Name"
+#define MListName L"Name"
+#define MListType L"Type"
+#define MListFile L"File"
+#define MListDir L"Directory"
+#define MListUSymlink L"Unix symbolic link"
+#define MListWSymlink L"Windows symbolic link"
+#define MListJunction L"NTFS junction point"
+#define MListHardlink L"Hard link"
+#define MListCopy L"File copy"
+#define MListStream L"NTFS alternate data stream"
+#define MListTarget L"Target"
+#define MListSize L"Size"
+#define MListPacked L"Packed size"
+#define MListRatio L"Ratio"
+#define MListMtime L"mtime"
+#define MListCtime L"ctime"
+#define MListAtime L"atime"
+#define MListAttr L"Attributes"
+#define MListFlags L"Flags"
+#define MListCompInfo L"Compression"
+#define MListHostOS L"Host OS"
+#define MListFileVer L"File version"
+#define MListService L"Service"
+#define MListEAHead L"\n OS/2 extended attributes"
+#define MListUOHead L"\n Unix Owner/Group data: %-14s %-14s"
+#define MListBeEAHead L"\n BeOS extended attributes"
+#define MListNTACLHead L"\n NTFS security data"
+#define MListStrmHead L"\n NTFS stream: %s"
+#define MListUnkHead L"\n Unknown subheader type: 0x%04x"
+#define MFileComment L"\nComment: "
+#define MYes L"Yes"
+#define MNo L"No"
+#define MListNoFiles L" 0 files\n"
+#define MRprReconstr L"\nReconstructing %s"
+#define MRprBuild L"\nBuilding %s"
+#define MRprOldFormat L"\nCannot repair archive with old format"
+#define MRprFind L"\nFound %s"
+#define MRprAskIsSol L"\nThe archive header is corrupt. Mark archive as solid ?"
+#define MRprNoFiles L"\nNo files found"
+#define MLogUnexpEOF L"\nUnexpected end of archive"
+#define MRepAskReconst L"\nReconstruct archive structure ?"
+#define MRecScanning L"\nScanning..."
+#define MRecRNotFound L"\nData recovery record not found"
+#define MRecRFound L"\nData recovery record found"
+#define MRecSecDamage L"\nSector %ld (offsets %lX...%lX) damaged"
+#define MRecCorrected L" - data recovered"
+#define MRecFailed L" - cannot recover data"
+#define MAddRecRec L"\nAdding data recovery record"
+#define MEraseForVolume L"\n\nErasing contents of drive %c:\n"
+#define MGetOwnersError L"\nWARNING: Cannot get %s owner and group\n"
+#define MErrGetOwnerID L"\nWARNING: Cannot get owner %s ID\n"
+#define MErrGetGroupID L"\nWARNING: Cannot get group %s ID\n"
+#define MOwnersBroken L"\nERROR: %s group and owner data are corrupt\n"
+#define MSetOwnersError L"\nWARNING: Cannot set %s owner and group\n"
+#define MErrLnkRead L"\nWARNING: Cannot read symbolic link %s"
+#define MSymLinkExists L"\nWARNING: Symbolic link %s already exists"
+#define MAskRetryCreate L"\nCannot create %s. Retry ?"
+#define MListMACHead1 L"\n Mac OS file type: %c%c%c%c ; "
+#define MListMACHead2 L"file creator: %c%c%c%c\n"
+#define MDataBadCRC L"\n%-20s : packed data checksum error in volume %s"
+#define MFileRO L"\n%s is read-only"
+#define MACLGetError L"\nWARNING: Cannot get %s security data\n"
+#define MACLSetError L"\nWARNING: Cannot set %s security data\n"
+#define MACLBroken L"\nERROR: %s security data are corrupt\n"
+#define MACLUnknown L"\nWARNING: Unknown format of %s security data\n"
+#define MStreamBroken L"\nERROR: %s stream data are corrupt\n"
+#define MStreamUnknown L"\nWARNING: Unknown format of %s stream data\n"
+#define MInvalidName L"\nERROR: Invalid file name %s"
+#define MEABroken L"\nERROR: %s extended attributes are corrupt\n"
+#define MEAUnknHeader L"\nWARNING: %s - unknown format of extended attributes\n"
+#define MCannotSetEA L"\nWARNING: cannot set extended attributes to %s\n"
+#define MCannotGetEA L"\nERROR: Cannot get extended attributes of %s\n"
+#define MShowEA L" (+EA)"
+#define MSkipEA L"\n...skipping extended attributes"
+#define MProcessArc L"\n\nProcessing archive %s"
+#define MSyncScanError L"\nFile search errors, cannot synchronize archive"
+#define MCorrectingName L"\nWARNING: Attempting to correct the invalid file name"
+#define MUnpCannotMerge L"\nWARNING: You need to start extraction from a previous volume to unpack %s"
+#define MUnknownOption L"\nERROR: Unknown option: %s"
+#define MSubHeadCorrupt L"\nERROR: Corrupt data header found, ignored"
+#define MSubHeadUnknown L"\nWARNING: Unknown data header format, ignored"
+#define MSubHeadDataCRC L"\nERROR: Corrupt %s data block"
+#define MSubHeadType L"\nData header type: %s"
+#define MScanError L"\nCannot read contents of %s"
+#define MNotVolume L"\n%s is not volume"
+#define MRecVolDiffSets L"\nERROR: %s and %s belong to different sets"
+#define MRecVolMissing L"\n%d volumes missing"
+#define MRecVolFound L"\n%d recovery volumes found"
+#define MRecVolAllExist L"\nNothing to reconstruct"
+#define MRecVolCannotFix L"\nReconstruction impossible"
+#define MReconstructing L"\nReconstructing..."
+#define MCreating L"\nCreating %s"
+#define MRenaming L"\nRenaming %s to %s"
+#define MNTFSRequired L"\nWrite error: only NTFS file system supports files larger than 4 GB"
+#define MErrChangeAttr L"\nWARNING: Cannot change attributes of %s"
+#define MWrongSFXVer L"\nERROR: default SFX module does not support RAR %d.%d archives"
+#define MCannotEncName L"\nCannot encrypt archive already contained encrypted files"
+#define MCannotEmail L"\nCannot email the file %s"
+#define MCopyrightS L"\nRAR SFX archive"
+#define MSHelpCmd L"\n\n<Commands>"
+#define MSHelpCmdE L"\n -x Extract from archive (default)"
+#define MSHelpCmdT L"\n -t Test archive files"
+#define MSHelpCmdV L"\n -v Verbosely list contents of archive"
+#define MRecVolLimit L"\nTotal number of usual and recovery volumes must not exceed %d"
+#define MVolumeNumber L"volume %d"
+#define MCannotDelete L"\nCannot delete %s"
+#define MCalcCRC L"\nCalculating the checksum"
+#define MTooLargeSFXArc L"\nWARNING: Too large SFX archive. Windows cannot run the executable file exceeding 4 GB."
+#define MCalcCRCAllVol L"\nCalculating checksums of all volumes."
+#define MNotEnoughDisk L"\nERROR: Not enough disk space for %s."
+#define MNewerRAR L"\nYou may need a newer version of RAR."
+#define MUnkEncMethod L"\nUnknown encryption method in %s"
+#define MWrongPassword L"\nThe specified password is incorrect."
+#define MRepairing L"\nRepairing"
+#define MAreaDamaged L"\nCorrupt %d bytes at %08x %08x"
+#define MBlocksRecovered L"\n%d blocks recovered."
+#define MRRDamaged L"\nRecovery record is corrupt."
+#define MTestingRR L"\nTesting the recovery record"
+#define MFailed L"Failed"
+#define MIncompatSwitch L"\n%s switch is not supported for RAR %d.x archive format."
+#define MSearchDupFiles L"\nSearching for identical files"
+#define MNumFound L"%d found."
+#define MUnknownExtra L"\nUnknown extra field in %s."
+#define MCopyError L"\nCannot copy %s to %s."
+#define MCopyErrorHint L"\nYou need to unpack the entire archive to create file copy entries."
+#define MCopyingData L"\nCopying data"
+#define MErrCreateLnkS L"\nCannot create symbolic link %s"
+#define MErrCreateLnkH L"\nCannot create hard link %s"
+#define MNeedAdmin L"\nYou may need to run RAR as administrator"
+#define MDictOutMem L"\nNot enough memory for %d MB compression dictionary, changed to %d MB."
+#define MUseSmalllerDict L"\nPlease use a smaller compression dictionary."
diff --git a/src/thirdparty/unrar/log.cpp b/src/thirdparty/unrar/log.cpp
index 965c16ce6..8bbe8ee0b 100644
--- a/src/thirdparty/unrar/log.cpp
+++ b/src/thirdparty/unrar/log.cpp
@@ -17,7 +17,7 @@ void Log(const wchar *ArcName,const wchar *fmt,...)
// Preserve the error code for possible following system error message.
int Code=ErrHandler.GetSystemErrorCode();
- Alarm();
+ uiAlarm(UIALARM_ERROR);
// This buffer is for format string only, not for entire output,
// so it can be short enough.
diff --git a/src/thirdparty/unrar/model.cpp b/src/thirdparty/unrar/model.cpp
index fb28c0774..0b2e5c343 100644
--- a/src/thirdparty/unrar/model.cpp
+++ b/src/thirdparty/unrar/model.cpp
@@ -5,10 +5,17 @@
* Contents: model description and encoding/decoding routines *
****************************************************************************/
-inline PPM_CONTEXT* PPM_CONTEXT::createChild(ModelPPM *Model,STATE* pStats,
- STATE& FirstState)
+static const int MAX_O=64; /* maximum allowed model order */
+const uint TOP=1 << 24, BOT=1 << 15;
+
+template <class T>
+inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; }
+
+
+inline RARPPM_CONTEXT* RARPPM_CONTEXT::createChild(ModelPPM *Model,RARPPM_STATE* pStats,
+ RARPPM_STATE& FirstState)
{
- PPM_CONTEXT* pc = (PPM_CONTEXT*) Model->SubAlloc.AllocContext();
+ RARPPM_CONTEXT* pc = (RARPPM_CONTEXT*) Model->SubAlloc.AllocContext();
if ( pc )
{
pc->NumStats=1;
@@ -34,11 +41,11 @@ void ModelPPM::RestartModelRare()
memset(CharMask,0,sizeof(CharMask));
SubAlloc.InitSubAllocator();
InitRL=-(MaxOrder < 12 ? MaxOrder:12)-1;
- MinContext = MaxContext = (PPM_CONTEXT*) SubAlloc.AllocContext();
+ MinContext = MaxContext = (RARPPM_CONTEXT*) SubAlloc.AllocContext();
MinContext->Suffix=NULL;
OrderFall=MaxOrder;
MinContext->U.SummFreq=(MinContext->NumStats=256)+1;
- FoundState=MinContext->U.Stats=(STATE*)SubAlloc.AllocUnits(256/2);
+ FoundState=MinContext->U.Stats=(RARPPM_STATE*)SubAlloc.AllocUnits(256/2);
for (RunLength=InitRL, PrevSuccess=i=0;i < 256;i++)
{
MinContext->U.Stats[i].Symbol=i;
@@ -105,10 +112,10 @@ void ModelPPM::StartModelRare(int MaxOrder)
}
-void PPM_CONTEXT::rescale(ModelPPM *Model)
+void RARPPM_CONTEXT::rescale(ModelPPM *Model)
{
int OldNS=NumStats, i=NumStats-1, Adder, EscFreq;
- STATE* p1, * p;
+ RARPPM_STATE* p1, * p;
for (p=Model->FoundState;p != U.Stats;p--)
_PPMD_SWAP(p[0],p[-1]);
U.Stats->Freq += 4;
@@ -122,7 +129,7 @@ void PPM_CONTEXT::rescale(ModelPPM *Model)
U.SummFreq += (p->Freq=(p->Freq+Adder) >> 1);
if (p[0].Freq > p[-1].Freq)
{
- STATE tmp=*(p1=p);
+ RARPPM_STATE tmp=*(p1=p);
do
{
p1[0]=p1[-1];
@@ -139,7 +146,7 @@ void PPM_CONTEXT::rescale(ModelPPM *Model)
EscFreq += i;
if ((NumStats -= i) == 1)
{
- STATE tmp=*U.Stats;
+ RARPPM_STATE tmp=*U.Stats;
do
{
tmp.Freq-=(tmp.Freq >> 1);
@@ -152,19 +159,19 @@ void PPM_CONTEXT::rescale(ModelPPM *Model)
U.SummFreq += (EscFreq -= (EscFreq >> 1));
int n0=(OldNS+1) >> 1, n1=(NumStats+1) >> 1;
if (n0 != n1)
- U.Stats = (STATE*) Model->SubAlloc.ShrinkUnits(U.Stats,n0,n1);
+ U.Stats = (RARPPM_STATE*) Model->SubAlloc.ShrinkUnits(U.Stats,n0,n1);
Model->FoundState=U.Stats;
}
-inline PPM_CONTEXT* ModelPPM::CreateSuccessors(bool Skip,STATE* p1)
+inline RARPPM_CONTEXT* ModelPPM::CreateSuccessors(bool Skip,RARPPM_STATE* p1)
{
#ifdef __ICL
static
#endif
- STATE UpState;
- PPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
- STATE * p, * ps[MAX_O], ** pps=ps;
+ RARPPM_STATE UpState;
+ RARPPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
+ RARPPM_STATE * p, * ps[MAX_O], ** pps=ps;
if ( !Skip )
{
*pps++ = FoundState;
@@ -202,7 +209,7 @@ NO_LOOP:
if (pps == ps)
return pc;
UpState.Symbol=*(byte*) UpBranch;
- UpState.Successor=(PPM_CONTEXT*) (((byte*) UpBranch)+1);
+ UpState.Successor=(RARPPM_CONTEXT*) (((byte*) UpBranch)+1);
if (pc->NumStats != 1)
{
if ((byte*) pc <= SubAlloc.pText)
@@ -230,8 +237,8 @@ NO_LOOP:
inline void ModelPPM::UpdateModel()
{
- STATE fs = *FoundState, *p = NULL;
- PPM_CONTEXT *pc, *Successor;
+ RARPPM_STATE fs = *FoundState, *p = NULL;
+ RARPPM_CONTEXT *pc, *Successor;
uint ns1, ns, cf, sf, s0;
if (fs.Freq < MAX_FREQ/4 && (pc=MinContext->Suffix) != NULL)
{
@@ -269,7 +276,7 @@ inline void ModelPPM::UpdateModel()
return;
}
*SubAlloc.pText++ = fs.Symbol;
- Successor = (PPM_CONTEXT*) SubAlloc.pText;
+ Successor = (RARPPM_CONTEXT*) SubAlloc.pText;
if (SubAlloc.pText >= SubAlloc.FakeUnitsStart)
goto RESTART_MODEL;
if ( fs.Successor )
@@ -295,7 +302,7 @@ inline void ModelPPM::UpdateModel()
{
if ((ns1 & 1) == 0)
{
- pc->U.Stats=(STATE*) SubAlloc.ExpandUnits(pc->U.Stats,ns1 >> 1);
+ pc->U.Stats=(RARPPM_STATE*) SubAlloc.ExpandUnits(pc->U.Stats,ns1 >> 1);
if ( !pc->U.Stats )
goto RESTART_MODEL;
}
@@ -303,7 +310,7 @@ inline void ModelPPM::UpdateModel()
}
else
{
- p=(STATE*) SubAlloc.AllocUnits(1);
+ p=(RARPPM_STATE*) SubAlloc.AllocUnits(1);
if ( !p )
goto RESTART_MODEL;
*p=pc->OneState;
@@ -346,9 +353,9 @@ static const byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2,
-inline void PPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
+inline void RARPPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
{
- STATE& rs=OneState;
+ RARPPM_STATE& rs=OneState;
Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
ushort& bs=Model->BinSumm[rs.Freq-1][Model->PrevSuccess+
Model->NS2BSIndx[Suffix->NumStats-1]+
@@ -378,7 +385,7 @@ inline void PPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
}
-inline void PPM_CONTEXT::update1(ModelPPM *Model,STATE* p)
+inline void RARPPM_CONTEXT::update1(ModelPPM *Model,RARPPM_STATE* p)
{
(Model->FoundState=p)->Freq += 4;
U.SummFreq += 4;
@@ -394,10 +401,10 @@ inline void PPM_CONTEXT::update1(ModelPPM *Model,STATE* p)
-inline bool PPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
+inline bool RARPPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
{
Model->Coder.SubRange.scale=U.SummFreq;
- STATE* p=U.Stats;
+ RARPPM_STATE* p=U.Stats;
int i, HiCnt;
int count=Model->Coder.GetCurrentCount();
if (count>=(int)Model->Coder.SubRange.scale)
@@ -439,7 +446,7 @@ inline bool PPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
}
-inline void PPM_CONTEXT::update2(ModelPPM *Model,STATE* p)
+inline void RARPPM_CONTEXT::update2(ModelPPM *Model,RARPPM_STATE* p)
{
(Model->FoundState=p)->Freq += 4;
U.SummFreq += 4;
@@ -450,9 +457,9 @@ inline void PPM_CONTEXT::update2(ModelPPM *Model,STATE* p)
}
-inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
+inline RARPPM_SEE2_CONTEXT* RARPPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
{
- SEE2_CONTEXT* psee2c;
+ RARPPM_SEE2_CONTEXT* psee2c;
if (NumStats != 256)
{
psee2c=Model->SEE2Cont[Model->NS2Indx[Diff-1]]+
@@ -472,11 +479,11 @@ inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
-inline bool PPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
+inline bool RARPPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
{
int count, HiCnt, i=NumStats-Model->NumMasked;
- SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
- STATE* ps[256], ** pps=ps, * p=U.Stats-1;
+ RARPPM_SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
+ RARPPM_STATE* ps[256], ** pps=ps, * p=U.Stats-1;
HiCnt=0;
do
{
diff --git a/src/thirdparty/unrar/model.hpp b/src/thirdparty/unrar/model.hpp
index 077742170..52abc89b3 100644
--- a/src/thirdparty/unrar/model.hpp
+++ b/src/thirdparty/unrar/model.hpp
@@ -4,16 +4,17 @@
#include "coder.hpp"
#include "suballoc.hpp"
-const int MAX_O=64; /* maximum allowed model order */
-
-const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
- INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
-
-#ifndef STRICT_ALIGNMENT_REQUIRED
+#ifdef ALLOW_MISALIGNED
#pragma pack(1)
#endif
-struct SEE2_CONTEXT
+struct RARPPM_DEF
+{
+ static const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
+ INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
+};
+
+struct RARPPM_SEE2_CONTEXT : RARPPM_DEF
{ // SEE-contexts for PPM-contexts with masked symbols
ushort Summ;
byte Shift, Count;
@@ -40,45 +41,47 @@ struct SEE2_CONTEXT
class ModelPPM;
-struct PPM_CONTEXT;
+struct RARPPM_CONTEXT;
-struct STATE
+struct RARPPM_STATE
{
byte Symbol;
byte Freq;
- PPM_CONTEXT* Successor;
+ RARPPM_CONTEXT* Successor;
};
-struct FreqData
-{
- ushort SummFreq;
- STATE _PACK_ATTR * Stats;
-};
-struct PPM_CONTEXT
+struct RARPPM_CONTEXT : RARPPM_DEF
{
ushort NumStats;
+
+ struct FreqData
+ {
+ ushort SummFreq;
+ RARPPM_STATE RARPPM_PACK_ATTR * Stats;
+ };
+
union
{
FreqData U;
- STATE OneState;
+ RARPPM_STATE OneState;
};
- PPM_CONTEXT* Suffix;
+ RARPPM_CONTEXT* Suffix;
inline void encodeBinSymbol(ModelPPM *Model,int symbol); // MaxOrder:
inline void encodeSymbol1(ModelPPM *Model,int symbol); // ABCD context
inline void encodeSymbol2(ModelPPM *Model,int symbol); // BCD suffix
inline void decodeBinSymbol(ModelPPM *Model); // BCDE successor
inline bool decodeSymbol1(ModelPPM *Model); // other orders:
inline bool decodeSymbol2(ModelPPM *Model); // BCD context
- inline void update1(ModelPPM *Model,STATE* p); // CD suffix
- inline void update2(ModelPPM *Model,STATE* p); // BCDE successor
+ inline void update1(ModelPPM *Model,RARPPM_STATE* p); // CD suffix
+ inline void update2(ModelPPM *Model,RARPPM_STATE* p); // BCDE successor
void rescale(ModelPPM *Model);
- inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState);
- inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
+ inline RARPPM_CONTEXT* createChild(ModelPPM *Model,RARPPM_STATE* pStats,RARPPM_STATE& FirstState);
+ inline RARPPM_SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
};
-#ifndef STRICT_ALIGNMENT_REQUIRED
+#ifdef ALLOW_MISALIGNED
#ifdef _AIX
#pragma pack(pop)
#else
@@ -86,28 +89,15 @@ struct PPM_CONTEXT
#endif
#endif
-const uint UNIT_SIZE=Max(sizeof(PPM_CONTEXT),sizeof(RAR_MEM_BLK));
-const uint FIXED_UNIT_SIZE=12;
-
-/*
-inline PPM_CONTEXT::PPM_CONTEXT(STATE* pStats,PPM_CONTEXT* ShorterContext):
- NumStats(1), Suffix(ShorterContext) { pStats->Successor=this; }
-inline PPM_CONTEXT::PPM_CONTEXT(): NumStats(0) {}
-*/
-
-template <class T>
-inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; }
-
-
-class ModelPPM
+class ModelPPM : RARPPM_DEF
{
private:
- friend struct PPM_CONTEXT;
+ friend struct RARPPM_CONTEXT;
- SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
+ RARPPM_SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
- struct PPM_CONTEXT *MinContext, *MedContext, *MaxContext;
- STATE* FoundState; // found next state transition
+ struct RARPPM_CONTEXT *MinContext, *MedContext, *MaxContext;
+ RARPPM_STATE* FoundState; // found next state transition
int NumMasked, InitEsc, OrderFall, MaxOrder, RunLength, InitRL;
byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
byte EscCount, PrevSuccess, HiBitsFlag;
@@ -118,7 +108,7 @@ class ModelPPM
void RestartModelRare();
void StartModelRare(int MaxOrder);
- inline PPM_CONTEXT* CreateSuccessors(bool Skip,STATE* p1);
+ inline RARPPM_CONTEXT* CreateSuccessors(bool Skip,RARPPM_STATE* p1);
inline void UpdateModel();
inline void ClearMask();
diff --git a/src/thirdparty/unrar/options.cpp b/src/thirdparty/unrar/options.cpp
index 031535462..b53edc668 100644
--- a/src/thirdparty/unrar/options.cpp
+++ b/src/thirdparty/unrar/options.cpp
@@ -22,7 +22,6 @@ void RAROptions::Init()
Method=3;
MsgStream=MSG_STDOUT;
ConvertNames=NAMES_ORIGINALCASE;
- ProcessEA=true;
xmtime=EXTTIME_HIGH3;
FileSizeLess=INT64NDF;
FileSizeMore=INT64NDF;
diff --git a/src/thirdparty/unrar/options.hpp b/src/thirdparty/unrar/options.hpp
index 283297c53..7b61ba2fb 100644
--- a/src/thirdparty/unrar/options.hpp
+++ b/src/thirdparty/unrar/options.hpp
@@ -165,7 +165,9 @@ class RAROptions
uint Threads; // We use it to init hash even if RAR_SMP is not defined.
-
+#ifdef _ANDROID
+ int64 FreeMem;
+#endif
diff --git a/src/thirdparty/unrar/os.hpp b/src/thirdparty/unrar/os.hpp
index ed76a1935..95fa5d6d3 100644
--- a/src/thirdparty/unrar/os.hpp
+++ b/src/thirdparty/unrar/os.hpp
@@ -42,11 +42,10 @@
#include <shlobj.h>
#include <winioctl.h>
#include <wincrypt.h>
-
-
#include <wchar.h>
#include <wctype.h>
+
#endif // _WIN_ALL
#include <sys/types.h>
@@ -88,8 +87,7 @@
#define DefLogName L"rar.log"
-#define PATHDIVIDER "\\"
-#define PATHDIVIDERW L"\\"
+#define SPATHDIVIDER L"\\"
#define CPATHDIVIDER '\\'
#define MASKALL L"*"
@@ -130,7 +128,12 @@
#include <sys/sysctl.h>
#endif
#ifndef SFX_MODULE
- #include <sys/statvfs.h>
+ #ifdef _ANDROID
+ #include <sys/vfs.h>
+ #define statvfs statfs
+ #else
+ #include <sys/statvfs.h>
+ #endif
#endif
#if defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined(__APPLE__)
#endif
@@ -161,8 +164,7 @@
#define DefLogName L".rarlog"
-#define PATHDIVIDER "/"
-#define PATHDIVIDERW L"/"
+#define SPATHDIVIDER L"/"
#define CPATHDIVIDER '/'
#define MASKALL L"*"
@@ -195,7 +197,7 @@
#endif
- typedef const char* MSGID;
+ typedef const wchar* MSGID;
#ifndef SSE_ALIGNMENT // No SSE use and no special data alignment is required.
#define SSE_ALIGNMENT 1
@@ -233,15 +235,9 @@
#endif
#endif
-#if !defined(BIG_ENDIAN) && defined(_WIN_ALL)
+#if !defined(BIG_ENDIAN) && defined(_WIN_ALL) || defined(__i386__) || defined(__x86_64__)
// Allow not aligned integer access, increases speed in some operations.
-#define ALLOW_NOT_ALIGNED_INT
-#endif
-
-#if defined(__sparc) || defined(sparc) || defined(__sparcv9)
-// Prohibit not aligned access to data structures in text compression
-// algorithm, increases memory requirements.
-#define STRICT_ALIGNMENT_REQUIRED
+#define ALLOW_MISALIGNED
#endif
#endif // _RAR_OS_
diff --git a/src/thirdparty/unrar/pathfn.cpp b/src/thirdparty/unrar/pathfn.cpp
index 1a85d548c..9f55f480c 100644
--- a/src/thirdparty/unrar/pathfn.cpp
+++ b/src/thirdparty/unrar/pathfn.cpp
@@ -71,44 +71,39 @@ void SetName(wchar *FullName,const wchar *Name,size_t MaxSize)
}
-void SetExt(wchar *Name,const wchar *NewExt)
+void SetExt(wchar *Name,const wchar *NewExt,size_t MaxSize)
{
if (Name==NULL || *Name==0)
return;
wchar *Dot=GetExt(Name);
- if (NewExt==NULL)
+ if (Dot!=NULL)
+ *Dot=0;
+ if (NewExt!=NULL)
{
- if (Dot!=NULL)
- *Dot=0;
+ wcsncatz(Name,L".",MaxSize);
+ wcsncatz(Name,NewExt,MaxSize);
}
- else
- if (Dot==NULL)
- {
- wcscat(Name,L".");
- wcscat(Name,NewExt);
- }
- else
- wcscpy(Dot+1,NewExt);
}
#ifndef SFX_MODULE
-void SetSFXExt(wchar *SFXName)
+void SetSFXExt(wchar *SFXName,size_t MaxSize)
{
if (SFXName==NULL || *SFXName==0)
return;
#ifdef _UNIX
- SetExt(SFXName,L"sfx");
+ SetExt(SFXName,L"sfx",MaxSize);
#endif
#if defined(_WIN_ALL) || defined(_EMX)
- SetExt(SFXName,L"exe");
+ SetExt(SFXName,L"exe",MaxSize);
#endif
}
#endif
+// 'Ext' is an extension with the leading dot, like L".rar".
wchar *GetExt(const wchar *Name)
{
return Name==NULL ? NULL:wcsrchr(PointToName(Name),'.');
@@ -162,7 +157,7 @@ void AddEndSlash(wchar *Path,size_t MaxLength)
{
size_t Length=wcslen(Path);
if (Length>0 && Path[Length-1]!=CPATHDIVIDER && Length+1<MaxLength)
- wcscat(Path,PATHDIVIDERW);
+ wcscat(Path,SPATHDIVIDER);
}
@@ -424,6 +419,7 @@ void MakeNameUsable(char *Name,bool Extended)
#ifndef _UNIX
if (s-Name>1 && *s==':')
*s='_';
+ // Remove ' ' and '.' before path separator, but allow .\ and ..\.
if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1]))
*s='_';
#endif
@@ -440,6 +436,7 @@ void MakeNameUsable(wchar *Name,bool Extended)
#ifndef _UNIX
if (s-Name>1 && *s==':')
*s='_';
+ // Remove ' ' and '.' before path separator, but allow .\ and ..\.
if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1]))
*s='_';
#endif
@@ -447,91 +444,39 @@ void MakeNameUsable(wchar *Name,bool Extended)
}
-char* UnixSlashToDos(char *SrcName,char *DestName,size_t MaxLength)
+void UnixSlashToDos(const char *SrcName,char *DestName,size_t MaxLength)
{
- if (DestName!=NULL && DestName!=SrcName)
- if (strlen(SrcName)>=MaxLength)
- {
- *DestName=0;
- return DestName;
- }
- else
- strcpy(DestName,SrcName);
- for (char *s=SrcName;*s!=0;s=charnext(s))
- {
- if (*s=='/')
- if (DestName==NULL)
- *s='\\';
- else
- DestName[s-SrcName]='\\';
- }
- return DestName==NULL ? SrcName:DestName;
+ size_t Copied=0;
+ for (;Copied<MaxLength-1 && SrcName[Copied]!=0;Copied++)
+ DestName[Copied]=SrcName[Copied]=='/' ? '\\':SrcName[Copied];
+ DestName[Copied]=0;
}
-char* DosSlashToUnix(char *SrcName,char *DestName,size_t MaxLength)
+void DosSlashToUnix(const char *SrcName,char *DestName,size_t MaxLength)
{
- if (DestName!=NULL && DestName!=SrcName)
- if (strlen(SrcName)>=MaxLength)
- {
- *DestName=0;
- return DestName;
- }
- else
- strcpy(DestName,SrcName);
- for (char *s=SrcName;*s!=0;s=charnext(s))
- {
- if (*s=='\\')
- if (DestName==NULL)
- *s='/';
- else
- DestName[s-SrcName]='/';
- }
- return DestName==NULL ? SrcName:DestName;
+ size_t Copied=0;
+ for (;Copied<MaxLength-1 && SrcName[Copied]!=0;Copied++)
+ DestName[Copied]=SrcName[Copied]=='\\' ? '/':SrcName[Copied];
+ DestName[Copied]=0;
}
-wchar* UnixSlashToDos(wchar *SrcName,wchar *DestName,size_t MaxLength)
+void UnixSlashToDos(const wchar *SrcName,wchar *DestName,size_t MaxLength)
{
- if (DestName!=NULL && DestName!=SrcName)
- if (wcslen(SrcName)>=MaxLength)
- {
- *DestName=0;
- return DestName;
- }
- else
- wcscpy(DestName,SrcName);
- for (wchar *s=SrcName;*s!=0;s++)
- {
- if (*s=='/')
- if (DestName==NULL)
- *s='\\';
- else
- DestName[s-SrcName]='\\';
- }
- return DestName==NULL ? SrcName:DestName;
+ size_t Copied=0;
+ for (;Copied<MaxLength-1 && SrcName[Copied]!=0;Copied++)
+ DestName[Copied]=SrcName[Copied]=='/' ? '\\':SrcName[Copied];
+ DestName[Copied]=0;
}
-wchar* DosSlashToUnix(wchar *SrcName,wchar *DestName,size_t MaxLength)
+void DosSlashToUnix(const wchar *SrcName,wchar *DestName,size_t MaxLength)
{
- if (DestName!=NULL && DestName!=SrcName)
- if (wcslen(SrcName)>=MaxLength)
- {
- *DestName=0;
- return DestName;
- }
- else
- wcscpy(DestName,SrcName);
- for (wchar *s=SrcName;*s!=0;s++)
- {
- if (*s=='\\')
- if (DestName==NULL)
- *s='/';
- else
- DestName[s-SrcName]='/';
- }
- return DestName==NULL ? SrcName:DestName;
+ size_t Copied=0;
+ for (;Copied<MaxLength-1 && SrcName[Copied]!=0;Copied++)
+ DestName[Copied]=SrcName[Copied]=='\\' ? '/':SrcName[Copied];
+ DestName[Copied]=0;
}
@@ -642,10 +587,10 @@ int ParseVersionFileName(wchar *Name,bool Truncate)
#if !defined(SFX_MODULE) && !defined(SETUP)
// Get the name of first volume. Return the leftmost digit of volume number.
-wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumbering)
+wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,size_t MaxSize,bool NewNumbering)
{
if (FirstName!=VolName)
- wcscpy(FirstName,VolName);
+ wcsncpyz(FirstName,VolName,MaxSize);
wchar *VolNumStart=FirstName;
if (NewNumbering)
{
@@ -668,7 +613,7 @@ wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumberin
else
{
// Old volume numbering scheme. Just set the extension to ".rar".
- SetExt(FirstName,L"rar");
+ SetExt(FirstName,L"rar",MaxSize);
VolNumStart=GetExt(FirstName);
}
if (!FileExist(FirstName))
@@ -677,8 +622,8 @@ wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumberin
// check if volume with same name and any other extension is available.
// It can help in case of *.exe or *.sfx first volume.
wchar Mask[NM];
- wcscpy(Mask,FirstName);
- SetExt(Mask,L"*");
+ wcsncpyz(Mask,FirstName,ASIZE(Mask));
+ SetExt(Mask,L"*",ASIZE(Mask));
FindFile Find;
Find.SetMask(Mask);
FindData FD;
@@ -687,7 +632,7 @@ wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumberin
Archive Arc;
if (Arc.Open(FD.Name,0) && Arc.IsArchive(true) && Arc.FirstVolume)
{
- wcscpy(FirstName,FD.Name);
+ wcsncpyz(FirstName,FD.Name,MaxSize);
break;
}
}
diff --git a/src/thirdparty/unrar/pathfn.hpp b/src/thirdparty/unrar/pathfn.hpp
index 7914997de..ba8f07c5f 100644
--- a/src/thirdparty/unrar/pathfn.hpp
+++ b/src/thirdparty/unrar/pathfn.hpp
@@ -5,8 +5,8 @@ wchar* PointToName(const wchar *Path);
wchar* PointToLastChar(const wchar *Path);
wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath);
void SetName(wchar *FullName,const wchar *Name,size_t MaxSize);
-void SetExt(wchar *Name,const wchar *NewExt);
-void SetSFXExt(wchar *SFXName);
+void SetExt(wchar *Name,const wchar *NewExt,size_t MaxSize);
+void SetSFXExt(wchar *SFXName,size_t MaxSize);
wchar *GetExt(const wchar *Name);
bool CmpExt(const wchar *Name,const wchar *Ext);
bool IsWildcard(const wchar *Str);
@@ -25,16 +25,36 @@ void NextVolumeName(wchar *ArcName,uint MaxLength,bool OldNumbering);
bool IsNameUsable(const wchar *Name);
void MakeNameUsable(char *Name,bool Extended);
void MakeNameUsable(wchar *Name,bool Extended);
-char* UnixSlashToDos(char *SrcName,char *DestName=NULL,size_t MaxLength=NM);
-char* DosSlashToUnix(char *SrcName,char *DestName=NULL,size_t MaxLength=NM);
-wchar* UnixSlashToDos(wchar *SrcName,wchar *DestName=NULL,size_t MaxLength=NM);
-wchar* DosSlashToUnix(wchar *SrcName,wchar *DestName=NULL,size_t MaxLength=NM);
+
+void UnixSlashToDos(const char *SrcName,char *DestName,size_t MaxLength);
+void DosSlashToUnix(const char *SrcName,char *DestName,size_t MaxLength);
+void UnixSlashToDos(const wchar *SrcName,wchar *DestName,size_t MaxLength);
+void DosSlashToUnix(const wchar *SrcName,wchar *DestName,size_t MaxLength);
+
+inline void SlashToNative(const char *SrcName,char *DestName,size_t MaxLength)
+{
+#ifdef _WIN_ALL
+ UnixSlashToDos(SrcName,DestName,MaxLength);
+#else
+ DosSlashToUnix(SrcName,DestName,MaxLength);
+#endif
+}
+
+inline void SlashToNative(const wchar *SrcName,wchar *DestName,size_t MaxLength)
+{
+#ifdef _WIN_ALL
+ UnixSlashToDos(SrcName,DestName,MaxLength);
+#else
+ DosSlashToUnix(SrcName,DestName,MaxLength);
+#endif
+}
+
void ConvertNameToFull(const wchar *Src,wchar *Dest,size_t MaxSize);
bool IsFullPath(const wchar *Path);
bool IsDiskLetter(const wchar *Path);
void GetPathRoot(const wchar *Path,wchar *Root,size_t MaxSize);
int ParseVersionFileName(wchar *Name,bool Truncate);
-wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumbering);
+wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,size_t MaxSize,bool NewNumbering);
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW,size_t DestSize);
#ifndef SFX_MODULE
diff --git a/src/thirdparty/unrar/rar.cpp b/src/thirdparty/unrar/rar.cpp
index 089616ce9..6c8f07240 100644
--- a/src/thirdparty/unrar/rar.cpp
+++ b/src/thirdparty/unrar/rar.cpp
@@ -69,7 +69,8 @@ int main(int argc, char *argv[])
ShutdownOnClose=Cmd->Shutdown;
#endif
- InitConsoleOptions(Cmd->MsgStream,Cmd->Sound);
+ uiInit(Cmd->Sound);
+ InitConsoleOptions(Cmd->MsgStream);
InitLogOptions(Cmd->LogName,Cmd->ErrlogCharset);
ErrHandler.SetSilent(Cmd->AllYes || Cmd->MsgStream==MSG_NULL);
ErrHandler.SetShutdown(Cmd->Shutdown);
@@ -82,7 +83,7 @@ int main(int argc, char *argv[])
{
ErrHandler.SetErrorCode(ErrCode);
}
- catch (std::bad_alloc)
+ catch (std::bad_alloc&)
{
ErrHandler.MemoryErrorMsg();
ErrHandler.SetErrorCode(RARX_MEMORY);
diff --git a/src/thirdparty/unrar/rar.hpp b/src/thirdparty/unrar/rar.hpp
index 0fb4757d4..4f8cfd9e3 100644
--- a/src/thirdparty/unrar/rar.hpp
+++ b/src/thirdparty/unrar/rar.hpp
@@ -2,6 +2,7 @@
#define _RAR_RARCOMMON_
#include "raros.hpp"
+#include "rartypes.hpp"
#include "os.hpp"
#ifdef RARDLL
@@ -9,7 +10,6 @@
#endif
#include "version.hpp"
-#include "rartypes.hpp"
#include "rardefs.hpp"
#include "rarlang.hpp"
#include "unicode.hpp"
@@ -31,6 +31,7 @@
#include "strlist.hpp"
#include "file.hpp"
#include "crc.hpp"
+#include "ui.hpp"
#include "filefn.hpp"
#include "filestr.hpp"
#include "find.hpp"
@@ -84,4 +85,10 @@
#include "global.hpp"
+
+
+#ifdef _ANDROID
+#include "GUI/rarjni.hpp"
+#endif
+
#endif
diff --git a/src/thirdparty/unrar/rardefs.hpp b/src/thirdparty/unrar/rardefs.hpp
index ed8729b3d..93276233b 100644
--- a/src/thirdparty/unrar/rardefs.hpp
+++ b/src/thirdparty/unrar/rardefs.hpp
@@ -4,6 +4,9 @@
#define Min(x,y) (((x)<(y)) ? (x):(y))
#define Max(x,y) (((x)>(y)) ? (x):(y))
+// Universal replacement of abs function for non-int arguments.
+#define Abs(x) (((x)<0) ? -(x):(x))
+
#define ASIZE(x) (sizeof(x)/sizeof(x[0]))
// MAXPASSWORD is expected to be multiple of CRYPTPROTECTMEMORY_BLOCK_SIZE (16)
@@ -24,7 +27,7 @@
// for those function calls where we do not need it.
#define ignore_result(x) if (x)
-// Produce the value, which is larger than 'v' and aligned to 'a'.
+// Produce the value, which is equal or larger than 'v' and aligned to 'a'.
#define ALIGN_VALUE(v,a) (size_t(v) + ( (~size_t(v) + 1) & (a - 1) ) )
#endif
diff --git a/src/thirdparty/unrar/raros.hpp b/src/thirdparty/unrar/raros.hpp
index 7a8f6af4a..de3bbeb76 100644
--- a/src/thirdparty/unrar/raros.hpp
+++ b/src/thirdparty/unrar/raros.hpp
@@ -19,6 +19,11 @@
#endif
#endif
+#ifdef ANDROID
+ #define _UNIX
+ #define _ANDROID
+#endif
+
#ifdef __APPLE__
#define _UNIX
#define _APPLE
diff --git a/src/thirdparty/unrar/rarvm.cpp b/src/thirdparty/unrar/rarvm.cpp
index d29ce3ff9..f458eecb0 100644
--- a/src/thirdparty/unrar/rarvm.cpp
+++ b/src/thirdparty/unrar/rarvm.cpp
@@ -44,7 +44,7 @@ inline uint RarVM::GetValue(bool ByteMode,uint *Addr)
}
else
{
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED)
if (IS_VM_MEM(Addr))
{
byte *B=(byte *)Addr;
@@ -58,7 +58,7 @@ inline uint RarVM::GetValue(bool ByteMode,uint *Addr)
}
}
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED)
#define GET_VALUE(ByteMode,Addr) GetValue(ByteMode,(uint *)Addr)
#else
#define GET_VALUE(ByteMode,Addr) ((ByteMode) ? (*(byte *)(Addr)):GET_UINT32(*(uint *)(Addr)))
@@ -80,7 +80,7 @@ inline void RarVM::SetValue(bool ByteMode,uint *Addr,uint Value)
}
else
{
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED) || !defined(PRESENT_INT32)
if (IS_VM_MEM(Addr))
{
((byte *)Addr)[0]=(byte)Value;
@@ -96,7 +96,7 @@ inline void RarVM::SetValue(bool ByteMode,uint *Addr,uint Value)
}
}
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED) || !defined(PRESENT_INT32)
#define SET_VALUE(ByteMode,Addr,Value) SetValue(ByteMode,(uint *)Addr,Value)
#else
#define SET_VALUE(ByteMode,Addr,Value) ((ByteMode) ? (*(byte *)(Addr)=((byte)(Value))):(*(uint32 *)(Addr)=((uint32)(Value))))
@@ -105,7 +105,7 @@ inline void RarVM::SetValue(bool ByteMode,uint *Addr,uint Value)
void RarVM::SetLowEndianValue(uint *Addr,uint Value)
{
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED) || !defined(PRESENT_INT32)
((byte *)Addr)[0]=(byte)Value;
((byte *)Addr)[1]=(byte)(Value>>8);
((byte *)Addr)[2]=(byte)(Value>>16);
diff --git a/src/thirdparty/unrar/rawread.cpp b/src/thirdparty/unrar/rawread.cpp
index 2daad9119..9ae34972b 100644
--- a/src/thirdparty/unrar/rawread.cpp
+++ b/src/thirdparty/unrar/rawread.cpp
@@ -1,5 +1,12 @@
#include "rar.hpp"
+RawRead::RawRead()
+{
+ RawRead::SrcFile=NULL;
+ Reset();
+}
+
+
RawRead::RawRead(File *SrcFile)
{
RawRead::SrcFile=SrcFile;
diff --git a/src/thirdparty/unrar/rawread.hpp b/src/thirdparty/unrar/rawread.hpp
index 9eedd6254..3bdf81256 100644
--- a/src/thirdparty/unrar/rawread.hpp
+++ b/src/thirdparty/unrar/rawread.hpp
@@ -12,6 +12,7 @@ class RawRead
CryptData *Crypt;
#endif
public:
+ RawRead();
RawRead(File *SrcFile);
void Reset();
size_t Read(size_t Size);
@@ -32,6 +33,8 @@ class RawRead
size_t DataLeft() {return DataSize-ReadPos;}
size_t GetPos() {return ReadPos;}
void SetPos(size_t Pos) {ReadPos=Pos;}
+ void Skip(size_t Size) {ReadPos+=Size;}
+ void Rewind() {SetPos(0);}
#ifndef SHELL_EXT
void SetCrypt(CryptData *Crypt) {RawRead::Crypt=Crypt;}
#endif
@@ -39,50 +42,56 @@ class RawRead
uint64 RawGetV(const byte *Data,uint &ReadPos,uint DataSize,bool &Overflow);
-inline uint RawGet2(const byte *D)
+inline uint RawGet2(const void *Data)
{
+ byte *D=(byte *)Data;
return D[0]+(D[1]<<8);
}
-inline uint RawGet4(const byte *D)
+inline uint RawGet4(const void *Data)
{
+ byte *D=(byte *)Data;
return D[0]+(D[1]<<8)+(D[2]<<16)+(D[3]<<24);
}
-inline uint64 RawGet8(const byte *D)
+inline uint64 RawGet8(const void *Data)
{
+ byte *D=(byte *)Data;
return INT32TO64(RawGet4(D+4),RawGet4(D));
}
// We need these "put" functions also in UnRAR code. This is why they are
// in rawread.hpp file even though they are "write" functions.
-inline void RawPut2(uint Field,byte *Data)
+inline void RawPut2(uint Field,void *Data)
{
- Data[0]=(byte)(Field);
- Data[1]=(byte)(Field>>8);
+ byte *D=(byte *)Data;
+ D[0]=(byte)(Field);
+ D[1]=(byte)(Field>>8);
}
-inline void RawPut4(uint Field,byte *Data)
+inline void RawPut4(uint Field,void *Data)
{
- Data[0]=(byte)(Field);
- Data[1]=(byte)(Field>>8);
- Data[2]=(byte)(Field>>16);
- Data[3]=(byte)(Field>>24);
+ byte *D=(byte *)Data;
+ D[0]=(byte)(Field);
+ D[1]=(byte)(Field>>8);
+ D[2]=(byte)(Field>>16);
+ D[3]=(byte)(Field>>24);
}
-inline void RawPut8(uint64 Field,byte *Data)
+inline void RawPut8(uint64 Field,void *Data)
{
- Data[0]=(byte)(Field);
- Data[1]=(byte)(Field>>8);
- Data[2]=(byte)(Field>>16);
- Data[3]=(byte)(Field>>24);
- Data[4]=(byte)(Field>>32);
- Data[5]=(byte)(Field>>40);
- Data[6]=(byte)(Field>>48);
- Data[7]=(byte)(Field>>56);
+ byte *D=(byte *)Data;
+ D[0]=(byte)(Field);
+ D[1]=(byte)(Field>>8);
+ D[2]=(byte)(Field>>16);
+ D[3]=(byte)(Field>>24);
+ D[4]=(byte)(Field>>32);
+ D[5]=(byte)(Field>>40);
+ D[6]=(byte)(Field>>48);
+ D[7]=(byte)(Field>>56);
}
#endif
diff --git a/src/thirdparty/unrar/rdwrfn.cpp b/src/thirdparty/unrar/rdwrfn.cpp
index 18be483de..eb561481e 100644
--- a/src/thirdparty/unrar/rdwrfn.cpp
+++ b/src/thirdparty/unrar/rdwrfn.cpp
@@ -204,7 +204,7 @@ void ComprDataIO::ShowUnpRead(int64 ArcPos,int64 ArcSize)
int CurPercent=ToPercent(ArcPos,ArcSize);
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
{
- mprintf(L"\b\b\b\b%3d%%",CurPercent);
+ uiExtractProgress(CurUnpWrite,SrcArc->FileHead.UnpSize,ArcPos,ArcSize);
LastPercent=CurPercent;
}
}
@@ -280,5 +280,3 @@ void ComprDataIO::SetUnpackToMemory(byte *Addr,uint Size)
UnpackToMemoryAddr=Addr;
UnpackToMemorySize=Size;
}
-
-
diff --git a/src/thirdparty/unrar/rdwrfn.hpp b/src/thirdparty/unrar/rdwrfn.hpp
index 408ee3d2a..c61128d77 100644
--- a/src/thirdparty/unrar/rdwrfn.hpp
+++ b/src/thirdparty/unrar/rdwrfn.hpp
@@ -67,6 +67,7 @@ class ComprDataIO
void SetUnpackToMemory(byte *Addr,uint Size);
void SetCurrentCommand(wchar Cmd) {CurrentCommand=Cmd;}
+
bool PackVolume;
bool UnpVolume;
bool NextVolumeMissing;
diff --git a/src/thirdparty/unrar/recvol.cpp b/src/thirdparty/unrar/recvol.cpp
index d3d16dde9..beb2ce57f 100644
--- a/src/thirdparty/unrar/recvol.cpp
+++ b/src/thirdparty/unrar/recvol.cpp
@@ -11,7 +11,7 @@ bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (!Arc.Open(Name))
{
if (!Silent)
- ErrHandler.OpenErrorMsg(NULL,Name);
+ ErrHandler.OpenErrorMsg(Name);
return false;
}
diff --git a/src/thirdparty/unrar/recvol3.cpp b/src/thirdparty/unrar/recvol3.cpp
index 5c6a7d9b9..c733c63e0 100644
--- a/src/thirdparty/unrar/recvol3.cpp
+++ b/src/thirdparty/unrar/recvol3.cpp
@@ -77,7 +77,7 @@ void RSEncode::EncodeBuf()
bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
{
wchar ArcName[NM];
- wcscpy(ArcName,Name);
+ wcsncpyz(ArcName,Name,ASIZE(ArcName));
wchar *Ext=GetExt(ArcName);
bool NewStyle=false;
bool RevName=Ext!=NULL && wcsicomp(Ext,L".rev")==0;
@@ -105,7 +105,7 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
Archive Arc(Cmd);
if (Arc.WOpen(fd.Name) && Arc.IsArchive(true))
{
- wcscpy(ArcName,fd.Name);
+ wcsncpyz(ArcName,fd.Name,ASIZE(ArcName));
break;
}
}
@@ -116,23 +116,19 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
return false;
if (!Arc.Volume)
{
-#ifndef SILENT
- Log(ArcName,St(MNotVolume),ArcName);
-#endif
+ uiMsg(UIERROR_NOTVOLUME,ArcName);
return false;
}
bool NewNumbering=Arc.NewNumbering;
Arc.Close();
- wchar *VolNumStart=VolNameToFirstName(ArcName,ArcName,NewNumbering);
+ wchar *VolNumStart=VolNameToFirstName(ArcName,ArcName,ASIZE(ArcName),NewNumbering);
wchar RecVolMask[NM];
- wcscpy(RecVolMask,ArcName);
+ wcsncpyz(RecVolMask,ArcName,ASIZE(RecVolMask));
size_t BaseNamePartLength=VolNumStart-ArcName;
- wcscpy(RecVolMask+BaseNamePartLength,L"*.rev");
+ wcsncpyz(RecVolMask+BaseNamePartLength,L"*.rev",ASIZE(RecVolMask)-BaseNamePartLength);
-#ifndef SILENT
int64 RecFileSize=0;
-#endif
// We cannot display "Calculating CRC..." message here, because we do not
// know if we'll find any recovery volumes. We'll display it after finding
@@ -171,15 +167,11 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
{
if (!CalcCRCMessageDone)
{
-#ifndef SILENT
- mprintf(St(MCalcCRCAllVol));
-#endif
+ uiMsg(UIMSG_RECVOLCALCCHECKSUM);
CalcCRCMessageDone=true;
}
-#ifndef SILENT
- mprintf(L"\n%s",CurName);
-#endif
+ uiMsg(UIMSG_STRING,CurName);
File CurFile;
CurFile.TOpen(CurName);
@@ -195,9 +187,7 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
CalcFileSum(&CurFile,&CalcCRC,NULL,Cmd->Threads,Length-4);
if (FileCRC!=CalcCRC)
{
-#ifndef SILENT
- mprintf(St(MCRCFailed),CurName);
-#endif
+ uiMsg(UIMSG_CHECKSUM,CurName);
continue;
}
}
@@ -224,10 +214,8 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
continue;
if (RecVolNumber!=0 && RecVolNumber!=P[1] || FileNumber!=0 && FileNumber!=P[2])
{
-#ifndef SILENT
- Log(NULL,St(MRecVolDiffSets),CurName,PrevName);
-#endif
- return(false);
+ uiMsg(UIERROR_RECVOLDIFFSETS,CurName,PrevName);
+ return false;
}
RecVolNumber=P[1];
FileNumber=P[2];
@@ -236,17 +224,12 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
NewFile->TOpen(CurName);
SrcFile[FileNumber+P[0]-1]=NewFile;
FoundRecVolumes++;
-#ifndef SILENT
+
if (RecFileSize==0)
RecFileSize=NewFile->FileLength();
-#endif
}
-#ifndef SILENT
if (!Silent || FoundRecVolumes!=0)
- {
- mprintf(St(MRecVolFound),FoundRecVolumes);
- }
-#endif
+ uiMsg(UIMSG_RECVOLFOUND,FoundRecVolumes);
if (FoundRecVolumes==0)
return(false);
@@ -270,9 +253,8 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
{
if (NewFile->GetHeaderType()==HEAD_ENDARC)
{
-#ifndef SILENT
- mprintf(L"\n%s",ArcName);
-#endif
+ uiMsg(UIMSG_STRING,ArcName);
+
if (NewFile->EndArcHead.DataCRC)
{
uint CalcCRC;
@@ -280,9 +262,7 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (NewFile->EndArcHead.ArcDataCRC!=CalcCRC)
{
ValidVolume=false;
-#ifndef SILENT
- mprintf(St(MCRCFailed),ArcName);
-#endif
+ uiMsg(UIMSG_CHECKSUM,ArcName);
}
}
break;
@@ -296,10 +276,9 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
wchar NewName[NM];
wcscpy(NewName,ArcName);
wcscat(NewName,L".bad");
-#ifndef SILENT
- mprintf(St(MBadArc),ArcName);
- mprintf(St(MRenaming),ArcName,NewName);
-#endif
+
+ uiMsg(UIMSG_BADARCHIVE,ArcName);
+ uiMsg(UIMSG_RENAMING,ArcName,NewName);
RenameFile(ArcName,NewName);
}
NewFile->Seek(0,SEEK_SET);
@@ -310,16 +289,16 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
// so if we are called from extraction, we will be able to continue
// extracting. It may happen if .rar and .rev are on read-only disks
// like CDs.
- if (!NewFile->Create(ArcName))
+ if (!NewFile->Create(ArcName,FMF_WRITE|FMF_SHAREREAD))
{
// We need to display the title of operation before the error message,
// to make clear for user that create error is related to recovery
// volumes. This is why we cannot use WCreate call here. Title must be
// before create error, not after that.
-#ifndef SILENT
- mprintf(St(MReconstructing));
-#endif
- ErrHandler.CreateErrorMsg(NULL,ArcName);
+
+ uiMsg(UIERROR_RECVOLFOUND,FoundRecVolumes); // Intentionally not displayed in console mode.
+ uiMsg(UIERROR_RECONSTRUCTING);
+ ErrHandler.CreateErrorMsg(ArcName);
return false;
}
@@ -329,36 +308,28 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (CurArcNum==FileNumber-1)
wcscpy(LastVolName,ArcName);
-#ifndef SILENT
- mprintf(St(MAbsNextVol),ArcName);
-#endif
+ uiMsg(UIMSG_MISSINGVOL,ArcName);
}
SrcFile[CurArcNum]=(File*)NewFile;
NextVolumeName(ArcName,ASIZE(ArcName),!NewNumbering);
}
-#ifndef SILENT
- mprintf(St(MRecVolMissing),MissingVolumes);
-#endif
+ uiMsg(UIMSG_RECVOLMISSING,MissingVolumes);
if (MissingVolumes==0)
{
-#ifndef SILENT
- mprintf(St(MRecVolAllExist));
-#endif
+ uiMsg(UIERROR_RECVOLALLEXIST);
return false;
}
if (MissingVolumes>FoundRecVolumes)
{
-#ifndef SILENT
- mprintf(St(MRecVolCannotFix));
-#endif
+ uiMsg(UIERROR_RECVOLFOUND,FoundRecVolumes); // Intentionally not displayed in console mode.
+ uiMsg(UIERROR_RECVOLCANNOTFIX);
return false;
}
-#ifndef SILENT
- mprintf(St(MReconstructing));
-#endif
+
+ uiMsg(UIMSG_RECONSTRUCTING);
int TotalFiles=FileNumber+RecVolNumber;
int Erasures[256],EraSize=0;
@@ -367,13 +338,11 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (WriteFlags[I] || SrcFile[I]==NULL)
Erasures[EraSize++]=I;
-#ifndef SILENT
int64 ProcessedSize=0;
#ifndef GUI
int LastPercent=-1;
mprintf(L" ");
#endif
-#endif
// Size of per file buffer.
size_t RecBufferSize=TotalBufferSize/TotalFiles;
@@ -404,15 +373,14 @@ bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
}
if (MaxRead==0)
break;
-#ifndef SILENT
+
int CurPercent=ToPercent(ProcessedSize,RecFileSize);
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
{
- mprintf(L"\b\b\b\b%3d%%",CurPercent);
+ uiProcessProgress("RC",ProcessedSize,RecFileSize);
LastPercent=CurPercent;
}
ProcessedSize+=MaxRead;
-#endif
int BlockStart=0;
int BlockSize=MaxRead/ThreadNumber;
diff --git a/src/thirdparty/unrar/recvol5.cpp b/src/thirdparty/unrar/recvol5.cpp
index 7ca137fe0..4fafac501 100644
--- a/src/thirdparty/unrar/recvol5.cpp
+++ b/src/thirdparty/unrar/recvol5.cpp
@@ -170,7 +170,7 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
{
if (!Vol->Volume && !Vol->BrokenHeader)
{
- Log(ArcName,St(MNotVolume),ArcName);
+ uiMsg(UIERROR_NOTVOLUME,ArcName);
return false;
}
// We work with archive as with raw data file, so we do not want
@@ -197,7 +197,7 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
ItemPos=VolNum-1;
if (*FirstVolName==0)
- VolNameToFirstName(fd.Name,FirstVolName,true);
+ VolNameToFirstName(fd.Name,FirstVolName,ASIZE(FirstVolName),true);
}
}
if (ItemPos==-1)
@@ -213,16 +213,12 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
}
}
-#ifndef SILENT
if (!Silent || FoundRecVolumes!=0)
- {
- mprintf(St(MRecVolFound),FoundRecVolumes);
- }
-#endif
+ uiMsg(UIMSG_RECVOLFOUND,FoundRecVolumes);
if (FoundRecVolumes==0)
return false;
- mprintf(St(MCalcCRCAllVol));
+ uiMsg(UIMSG_RECVOLCALCCHECKSUM);
MissingVolumes=0;
for (uint I=0;I<TotalCount;I++)
@@ -230,13 +226,15 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
RecVolItem *Item=&RecItems[I];
if (Item->f!=NULL)
{
- mprintf(L"\n%s",Item->Name);
+ uiMsg(UIMSG_STRING,Item->Name);
+
uint RevCRC;
CalcFileSum(Item->f,&RevCRC,NULL,Cmd->Threads,INT64NDF,CALCFSUM_CURPOS);
Item->Valid=RevCRC==Item->CRC;
if (!Item->Valid)
{
- mprintf(St(MCRCFailed),Item->Name);
+ uiMsg(UIMSG_CHECKSUM,Item->Name);
+
// Close only corrupt REV volumes here. We'll close and rename corrupt
// RAR volumes later, if we'll know that recovery is possible.
if (I>=DataCount)
@@ -251,26 +249,30 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
MissingVolumes++;
}
- mprintf(St(MRecVolMissing),MissingVolumes);
+ uiMsg(UIMSG_RECVOLMISSING,MissingVolumes);
if (MissingVolumes==0)
{
- mprintf(St(MRecVolAllExist));
+ uiMsg(UIERROR_RECVOLALLEXIST);
return false;
}
if (MissingVolumes>FoundRecVolumes)
{
- mprintf(St(MRecVolCannotFix));
+ uiMsg(UIERROR_RECVOLFOUND,FoundRecVolumes); // Intentionally not displayed in console mode.
+ uiMsg(UIERROR_RECVOLCANNOTFIX);
return false;
}
- mprintf(St(MReconstructing));
+ uiMsg(UIMSG_RECONSTRUCTING);
// Create missing and rename bad volumes.
+ uint64 MaxVolSize=0;
for (uint I=0;I<DataCount;I++)
{
RecVolItem *Item=&RecItems[I];
+ if (Item->FileSize>MaxVolSize)
+ MaxVolSize=Item->FileSize;
if (Item->f!=NULL && !Item->Valid)
{
Item->f->Close();
@@ -278,10 +280,9 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
wchar NewName[NM];
wcscpy(NewName,Item->Name);
wcscat(NewName,L".bad");
-#ifndef SILENT
- mprintf(St(MBadArc),Item->Name);
- mprintf(St(MRenaming),Item->Name,NewName);
-#endif
+
+ uiMsg(UIMSG_BADARCHIVE,Item->Name);
+ uiMsg(UIMSG_RENAMING,Item->Name,NewName);
RenameFile(Item->Name,NewName);
delete Item->f;
Item->f=NULL;
@@ -290,13 +291,13 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (Item->New=(Item->f==NULL))
{
wcsncpyz(Item->Name,FirstVolName,ASIZE(Item->Name));
- mprintf(St(MCreating),Item->Name);
+ uiMsg(UIMSG_CREATING,Item->Name);
File *NewVol=new File;
bool UserReject;
- if (!FileCreate(Cmd,NewVol,Item->Name,ASIZE(Item->Name),Cmd->Overwrite,&UserReject))
+ if (!FileCreate(Cmd,NewVol,Item->Name,ASIZE(Item->Name),&UserReject))
{
if (!UserReject)
- ErrHandler.CreateErrorMsg(NULL,Item->Name);
+ ErrHandler.CreateErrorMsg(Item->Name);
ErrHandler.Exit(UserReject ? RARX_USERBREAK:RARX_CREATE);
}
NewVol->Prealloc(Item->FileSize);
@@ -367,7 +368,10 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (ReadSize>MaxRead)
MaxRead=ReadSize;
- ProcessRS(Cmd,I,B,MaxRead,false);
+ // We can have volumes of different size. Let's use data chunk
+ // for largest volume size.
+ uint DataToProcess=(uint)Min(RecBufferSize,MaxVolSize-ProcessedSize);
+ ProcessRS(Cmd,I,B,DataToProcess,false);
}
if (MaxRead==0)
break;
@@ -381,15 +385,13 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
Item->FileSize-=WriteSize;
}
-#ifndef SILENT
int CurPercent=ToPercent(ProcessedSize,RecFileSize);
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
{
- mprintf(L"\b\b\b\b%3d%%",CurPercent);
+ uiProcessProgress("RV",ProcessedSize,RecFileSize);
LastPercent=CurPercent;
}
ProcessedSize+=MaxRead;
-#endif
}
for (uint I=0;I<TotalCount;I++)
@@ -404,7 +406,7 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
if (!Silent && !Cmd->DisableDone)
mprintf(St(MDone));
#endif
- return(true);
+ return true;
}
diff --git a/src/thirdparty/unrar/resource.cpp b/src/thirdparty/unrar/resource.cpp
index 496f098c9..20a857570 100644
--- a/src/thirdparty/unrar/resource.cpp
+++ b/src/thirdparty/unrar/resource.cpp
@@ -5,14 +5,7 @@
#ifndef RARDLL
const wchar *St(MSGID StringId)
{
- static wchar StrTable[8][512];
- static int StrNum=0;
- if (++StrNum >= sizeof(StrTable)/sizeof(StrTable[0]))
- StrNum=0;
- wchar *Str=StrTable[StrNum];
- *Str=0;
- CharToWide(StringId,Str,ASIZE(StrTable[0]));
- return Str;
+ return StringId;
}
#endif
diff --git a/src/thirdparty/unrar/rijndael.cpp b/src/thirdparty/unrar/rijndael.cpp
index b267d6764..fa4f58849 100644
--- a/src/thirdparty/unrar/rijndael.cpp
+++ b/src/thirdparty/unrar/rijndael.cpp
@@ -7,22 +7,26 @@
***************************************************************************/
#include "rar.hpp"
+#ifdef USE_SSE
+#include <wmmintrin.h>
+#endif
+
static byte S[256],S5[256],rcon[30];
static byte T1[256][4],T2[256][4],T3[256][4],T4[256][4];
static byte T5[256][4],T6[256][4],T7[256][4],T8[256][4];
static byte U1[256][4],U2[256][4],U3[256][4],U4[256][4];
-inline void Xor128(byte *dest,const byte *arg1,const byte *arg2)
+inline void Xor128(void *dest,const void *arg1,const void *arg2)
{
-#if defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(PRESENT_INT32) && defined(ALLOW_MISALIGNED)
((uint32*)dest)[0]=((uint32*)arg1)[0]^((uint32*)arg2)[0];
((uint32*)dest)[1]=((uint32*)arg1)[1]^((uint32*)arg2)[1];
((uint32*)dest)[2]=((uint32*)arg1)[2]^((uint32*)arg2)[2];
((uint32*)dest)[3]=((uint32*)arg1)[3]^((uint32*)arg2)[3];
#else
for (int I=0;I<16;I++)
- dest[I]=arg1[I]^arg2[I];
+ ((byte*)dest)[I]=((byte*)arg1)[I]^((byte*)arg2)[I];
#endif
}
@@ -30,7 +34,7 @@ inline void Xor128(byte *dest,const byte *arg1,const byte *arg2)
inline void Xor128(byte *dest,const byte *arg1,const byte *arg2,
const byte *arg3,const byte *arg4)
{
-#if defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(PRESENT_INT32) && defined(ALLOW_MISALIGNED)
(*(uint32*)dest)=(*(uint32*)arg1)^(*(uint32*)arg2)^(*(uint32*)arg3)^(*(uint32*)arg4);
#else
for (int I=0;I<4;I++)
@@ -41,7 +45,7 @@ inline void Xor128(byte *dest,const byte *arg1,const byte *arg2,
inline void Copy128(byte *dest,const byte *src)
{
-#if defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(PRESENT_INT32) && defined(ALLOW_MISALIGNED)
((uint32*)dest)[0]=((uint32*)src)[0];
((uint32*)dest)[1]=((uint32*)src)[1];
((uint32*)dest)[2]=((uint32*)src)[2];
@@ -61,11 +65,20 @@ Rijndael::Rijndael()
{
if (S[0]==0)
GenerateTables();
+ CBCMode = true; // Always true for RAR.
}
void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVector)
{
+#ifdef USE_SSE
+ // Check SSE here instead of constructor, so if object is a part of some
+ // structure memset'ed before use, this variable is not lost.
+ int CPUInfo[4];
+ __cpuid(CPUInfo, 1);
+ AES_NI=(CPUInfo[2] & 0x2000000)!=0;
+#endif
+
uint uKeyLenInBytes;
switch(keyLen)
{
@@ -88,8 +101,11 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVe
for(uint i = 0; i < uKeyLenInBytes; i++)
keyMatrix[i >> 2][i & 3] = key[i];
- for(int i = 0; i < MAX_IV_SIZE; i++)
- m_initVector[i] = initVector[i];
+ if (initVector==NULL)
+ memset(m_initVector, 0, sizeof(m_initVector));
+ else
+ for(int i = 0; i < MAX_IV_SIZE; i++)
+ m_initVector[i] = initVector[i];
keySched(keyMatrix);
@@ -99,36 +115,109 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVe
-size_t Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer)
+void Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer)
{
- if (input == 0 || inputLen <= 0)
- return 0;
+ if (inputLen <= 0)
+ return;
+
+ size_t numBlocks=inputLen/16;
+#ifdef USE_SSE
+ if (AES_NI)
+ {
+ blockDecryptSSE(input,numBlocks,outBuffer);
+ return;
+ }
+#endif
byte block[16], iv[4][4];
memcpy(iv,m_initVector,16);
- size_t numBlocks=inputLen/16;
for (size_t i = numBlocks; i > 0; i--)
{
- decrypt(input, block);
- Xor128(block,block,(byte*)iv);
-#if STRICT_ALIGN
- memcpy(iv, input, 16);
- memcpy(outBuf, block, 16);
-#else
+ byte temp[4][4];
+
+ Xor128(temp,input,m_expandedKey[m_uRounds]);
+
+ Xor128(block, T5[temp[0][0]],T6[temp[3][1]],T7[temp[2][2]],T8[temp[1][3]]);
+ Xor128(block+4, T5[temp[1][0]],T6[temp[0][1]],T7[temp[3][2]],T8[temp[2][3]]);
+ Xor128(block+8, T5[temp[2][0]],T6[temp[1][1]],T7[temp[0][2]],T8[temp[3][3]]);
+ Xor128(block+12,T5[temp[3][0]],T6[temp[2][1]],T7[temp[1][2]],T8[temp[0][3]]);
+
+ for(int r = m_uRounds-1; r > 1; r--)
+ {
+ Xor128(temp,block,m_expandedKey[r]);
+ Xor128(block, T5[temp[0][0]],T6[temp[3][1]],T7[temp[2][2]],T8[temp[1][3]]);
+ Xor128(block+4, T5[temp[1][0]],T6[temp[0][1]],T7[temp[3][2]],T8[temp[2][3]]);
+ Xor128(block+8, T5[temp[2][0]],T6[temp[1][1]],T7[temp[0][2]],T8[temp[3][3]]);
+ Xor128(block+12,T5[temp[3][0]],T6[temp[2][1]],T7[temp[1][2]],T8[temp[0][3]]);
+ }
+
+ Xor128(temp,block,m_expandedKey[1]);
+ block[ 0] = S5[temp[0][0]];
+ block[ 1] = S5[temp[3][1]];
+ block[ 2] = S5[temp[2][2]];
+ block[ 3] = S5[temp[1][3]];
+ block[ 4] = S5[temp[1][0]];
+ block[ 5] = S5[temp[0][1]];
+ block[ 6] = S5[temp[3][2]];
+ block[ 7] = S5[temp[2][3]];
+ block[ 8] = S5[temp[2][0]];
+ block[ 9] = S5[temp[1][1]];
+ block[10] = S5[temp[0][2]];
+ block[11] = S5[temp[3][3]];
+ block[12] = S5[temp[3][0]];
+ block[13] = S5[temp[2][1]];
+ block[14] = S5[temp[1][2]];
+ block[15] = S5[temp[0][3]];
+ Xor128(block,block,m_expandedKey[0]);
+
+ if (CBCMode)
+ Xor128(block,block,iv);
+
Copy128((byte*)iv,input);
Copy128(outBuffer,block);
-#endif
+
input += 16;
outBuffer += 16;
}
memcpy(m_initVector,iv,16);
-
- return 16*numBlocks;
}
+#ifdef USE_SSE
+void Rijndael::blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer)
+{
+ __m128i initVector = _mm_loadu_si128((__m128i*)m_initVector);
+ __m128i *src=(__m128i*)input;
+ __m128i *dest=(__m128i*)outBuffer;
+ __m128i *rkey=(__m128i*)m_expandedKey;
+ while (numBlocks > 0)
+ {
+ __m128i rl = _mm_loadu_si128(rkey + m_uRounds);
+ __m128i d = _mm_loadu_si128(src++);
+ __m128i v = _mm_xor_si128(rl, d);
+
+ for (int i=m_uRounds-1; i>0; i--)
+ {
+ __m128i ri = _mm_loadu_si128(rkey + i);
+ v = _mm_aesdec_si128(v, ri);
+ }
+
+ __m128i r0 = _mm_loadu_si128(rkey);
+ v = _mm_aesdeclast_si128(v, r0);
+
+ if (CBCMode)
+ v = _mm_xor_si128(v, initVector);
+ initVector = d;
+ _mm_storeu_si128(dest++,v);
+ numBlocks--;
+ }
+ _mm_storeu_si128((__m128i*)m_initVector,initVector);
+}
+#endif
+
+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ALGORITHM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -221,47 +310,6 @@ void Rijndael::keyEncToDec()
}
-void Rijndael::decrypt(const byte a[16], byte b[16])
-{
- int r;
- byte temp[4][4];
-
- Xor128((byte*)temp,(byte*)a,(byte*)m_expandedKey[m_uRounds]);
-
- Xor128(b, T5[temp[0][0]],T6[temp[3][1]],T7[temp[2][2]],T8[temp[1][3]]);
- Xor128(b+4, T5[temp[1][0]],T6[temp[0][1]],T7[temp[3][2]],T8[temp[2][3]]);
- Xor128(b+8, T5[temp[2][0]],T6[temp[1][1]],T7[temp[0][2]],T8[temp[3][3]]);
- Xor128(b+12,T5[temp[3][0]],T6[temp[2][1]],T7[temp[1][2]],T8[temp[0][3]]);
-
- for(r = m_uRounds-1; r > 1; r--)
- {
- Xor128((byte*)temp,(byte*)b,(byte*)m_expandedKey[r]);
- Xor128(b, T5[temp[0][0]],T6[temp[3][1]],T7[temp[2][2]],T8[temp[1][3]]);
- Xor128(b+4, T5[temp[1][0]],T6[temp[0][1]],T7[temp[3][2]],T8[temp[2][3]]);
- Xor128(b+8, T5[temp[2][0]],T6[temp[1][1]],T7[temp[0][2]],T8[temp[3][3]]);
- Xor128(b+12,T5[temp[3][0]],T6[temp[2][1]],T7[temp[1][2]],T8[temp[0][3]]);
- }
-
- Xor128((byte*)temp,(byte*)b,(byte*)m_expandedKey[1]);
- b[ 0] = S5[temp[0][0]];
- b[ 1] = S5[temp[3][1]];
- b[ 2] = S5[temp[2][2]];
- b[ 3] = S5[temp[1][3]];
- b[ 4] = S5[temp[1][0]];
- b[ 5] = S5[temp[0][1]];
- b[ 6] = S5[temp[3][2]];
- b[ 7] = S5[temp[2][3]];
- b[ 8] = S5[temp[2][0]];
- b[ 9] = S5[temp[1][1]];
- b[10] = S5[temp[0][2]];
- b[11] = S5[temp[3][3]];
- b[12] = S5[temp[3][0]];
- b[13] = S5[temp[2][1]];
- b[14] = S5[temp[1][2]];
- b[15] = S5[temp[0][3]];
- Xor128((byte*)b,(byte*)b,(byte*)m_expandedKey[0]);
-}
-
#define ff_poly 0x011b
#define ff_hi 0x80
diff --git a/src/thirdparty/unrar/rijndael.hpp b/src/thirdparty/unrar/rijndael.hpp
index bf1439e69..2144e02e5 100644
--- a/src/thirdparty/unrar/rijndael.hpp
+++ b/src/thirdparty/unrar/rijndael.hpp
@@ -16,20 +16,29 @@
class Rijndael
{
private:
+#ifdef USE_SSE
+ void blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer);
+ void blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer);
+
+ bool AES_NI;
+#endif
void keySched(byte key[_MAX_KEY_COLUMNS][4]);
void keyEncToDec();
- void encrypt(const byte a[16], byte b[16]);
- void decrypt(const byte a[16], byte b[16]);
void GenerateTables();
+ // RAR always uses CBC, but we may need to turn it off when calling
+ // this code from other archive formats with CTR and other modes.
+ bool CBCMode;
+
int m_uRounds;
byte m_initVector[MAX_IV_SIZE];
byte m_expandedKey[_MAX_ROUNDS+1][4][4];
public:
Rijndael();
void Init(bool Encrypt,const byte *key,uint keyLen,const byte *initVector);
- size_t blockEncrypt(const byte *input, size_t inputLen, byte *outBuffer);
- size_t blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer);
+ void blockEncrypt(const byte *input, size_t inputLen, byte *outBuffer);
+ void blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer);
+ void SetCBCMode(bool Mode) {CBCMode=Mode;}
};
#endif // _RIJNDAEL_H_
diff --git a/src/thirdparty/unrar/scantree.cpp b/src/thirdparty/unrar/scantree.cpp
index 5bf170504..40e4e47c9 100644
--- a/src/thirdparty/unrar/scantree.cpp
+++ b/src/thirdparty/unrar/scantree.cpp
@@ -64,7 +64,7 @@ bool ScanTree::GetNextMask()
return false;
CurMask[ASIZE(CurMask)-1]=0;
#ifdef _WIN_ALL
- UnixSlashToDos(CurMask);
+ UnixSlashToDos(CurMask,CurMask,ASIZE(CurMask));
#endif
// We wish to scan entire disk if mask like c:\ is specified
@@ -253,10 +253,7 @@ SCAN_CODE ScanTree::FindProc(FindData *FD)
if (wcslen(CurMask)+wcslen(Mask)+1>=NM || Depth>=MAXSCANDEPTH-1)
{
-#ifndef SILENT
- Log(NULL,L"\n%ls%c%ls",CurMask,CPATHDIVIDER,Mask);
- Log(NULL,St(MPathTooLong));
-#endif
+ uiMsg(UIERROR_PATHTOOLONG,CurMask,SPATHDIVIDER,Mask);
return SCAN_ERROR;
}
@@ -325,14 +322,12 @@ void ScanTree::ScanError(bool &Error)
if (Error && Cmd!=NULL && Cmd->ExclCheck(CurMask,false,true,true))
Error=false;
-#ifndef SILENT
if (Error)
{
wchar FullName[NM];
// This conversion works for wildcard masks too.
ConvertNameToFull(CurMask,FullName,ASIZE(FullName));
- Log(NULL,St(MScanError),FullName);
+ uiMsg(UIERROR_DIRSCAN,FullName);
ErrHandler.SysErrMsg();
}
-#endif
}
diff --git a/src/thirdparty/unrar/sha1.cpp b/src/thirdparty/unrar/sha1.cpp
index 71045d856..5f182e563 100644
--- a/src/thirdparty/unrar/sha1.cpp
+++ b/src/thirdparty/unrar/sha1.cpp
@@ -59,7 +59,7 @@ static void wipevars(uint32 &a,uint32 &b,uint32 &c,uint32 &d,uint32 &e)
/* Hash a single 512-bit block. This is the core of the algorithm. */
-void SHA1Transform(uint32 state[5], unsigned char workspace[64], unsigned char buffer[64], bool handsoff)
+void SHA1Transform(uint32 state[5], unsigned char workspace[64], const byte buffer[64], bool handsoff)
{
#ifndef SFX_MODULE
uint32 a, b, c, d, e;
@@ -155,7 +155,7 @@ CHAR64LONG16* block;
/* Initialize new context */
-void hash_initial(hash_context* context)
+void sha1_init(sha1_context* context)
{
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
@@ -168,7 +168,7 @@ void hash_initial(hash_context* context)
/* Run your data through this. */
-void hash_process( hash_context * context, unsigned char * data, size_t len,
+void sha1_process( sha1_context * context, const unsigned char * data, size_t len,
bool handsoff )
{
unsigned int i, j;
@@ -181,13 +181,14 @@ uint blen = ((uint)len)<<3;
memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->workspace, context->buffer, handsoff);
for ( ; i + 63 < len; i += 64) {
-#ifdef ALLOW_NOT_ALIGNED_INT
+#ifdef ALLOW_MISALIGNED
SHA1Transform(context->state, context->workspace, &data[i], handsoff);
#else
- unsigned char buffer[64];
+ uint buffer[16];
memcpy(buffer,data+i,sizeof(buffer));
- SHA1Transform(context->state, context->workspace, buffer, handsoff);
- memcpy(data+i,buffer,sizeof(buffer));
+ SHA1Transform(context->state, context->workspace, (byte*)buffer, handsoff);
+ if (!handsoff)
+ memcpy((byte *)(data+i),buffer,sizeof(buffer));
#endif
#ifdef BIG_ENDIAN
if (!handsoff)
@@ -214,7 +215,7 @@ uint blen = ((uint)len)<<3;
/* Add padding and return the message digest. */
-void hash_final( hash_context* context, uint32 digest[5], bool handsoff)
+void sha1_done( sha1_context* context, uint32 digest[5], bool handsoff)
{
uint i, j;
unsigned char finalcount[8];
@@ -224,12 +225,12 @@ unsigned char finalcount[8];
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
unsigned char ch=(unsigned char)'\200';
- hash_process(context, &ch, 1, handsoff);
+ sha1_process(context, &ch, 1, handsoff);
while ((context->count[0] & 504) != 448) {
ch=0;
- hash_process(context, &ch, 1, handsoff);
+ sha1_process(context, &ch, 1, handsoff);
}
- hash_process(context, finalcount, 8, handsoff); /* Should cause a SHA1Transform() */
+ sha1_process(context, finalcount, 8, handsoff); /* Should cause a SHA1Transform() */
for (i = 0; i < 5; i++) {
digest[i] = context->state[i] & 0xffffffff;
}
diff --git a/src/thirdparty/unrar/sha1.hpp b/src/thirdparty/unrar/sha1.hpp
index f28403fd6..8407a2ddb 100644
--- a/src/thirdparty/unrar/sha1.hpp
+++ b/src/thirdparty/unrar/sha1.hpp
@@ -9,11 +9,11 @@ typedef struct {
unsigned char buffer[64];
unsigned char workspace[64]; // Temporary buffer.
-} hash_context;
+} sha1_context;
-void hash_initial( hash_context * c );
-void hash_process( hash_context * c, unsigned char * data, size_t len,
+void sha1_init( sha1_context * c );
+void sha1_process( sha1_context * c, const byte *data, size_t len,
bool handsoff);
-void hash_final( hash_context * c, uint32[HW], bool handsoff);
+void sha1_done( sha1_context * c, uint32[HW], bool handsoff);
#endif
diff --git a/src/thirdparty/unrar/sha256.cpp b/src/thirdparty/unrar/sha256.cpp
index 49859c0f8..180b3c476 100644
--- a/src/thirdparty/unrar/sha256.cpp
+++ b/src/thirdparty/unrar/sha256.cpp
@@ -53,6 +53,8 @@ inline uint32 b2i(const byte *b) // Big endian bytes to integer.
{
#if defined(_MSC_VER)/* && defined(LITTLE_ENDIAN)*/
return _byteswap_ulong(*(uint32 *)b);
+#elif (__GNUC__ > 3) && (__GNUC_MINOR__ > 2)
+ return __builtin_bswap32(*(uint32 *)b);
#else
return uint32(b[0]<<24) | uint32(b[1]<<16) | uint32(b[2]<<8) | b[3];
#endif
diff --git a/src/thirdparty/unrar/strfn.cpp b/src/thirdparty/unrar/strfn.cpp
index b180890b1..c2888a09c 100644
--- a/src/thirdparty/unrar/strfn.cpp
+++ b/src/thirdparty/unrar/strfn.cpp
@@ -2,13 +2,13 @@
const char *NullToEmpty(const char *Str)
{
- return(Str==NULL ? "":Str);
+ return Str==NULL ? "":Str;
}
const wchar *NullToEmpty(const wchar *Str)
{
- return(Str==NULL ? L"":Str);
+ return Str==NULL ? L"":Str;
}
@@ -17,6 +17,10 @@ void IntToExt(const char *Src,char *Dest,size_t DestSize)
#ifdef _WIN_ALL
OemToCharBuffA(Src,Dest,(DWORD)DestSize);
Dest[DestSize-1]=0;
+#elif defined(_ANDROID)
+ wchar DestW[NM];
+ UnkToWide(Src,DestW,ASIZE(DestW));
+ WideToChar(DestW,Dest,DestSize);
#else
if (Dest!=Src)
strncpyz(Dest,Src,DestSize);
@@ -27,7 +31,7 @@ void IntToExt(const char *Src,char *Dest,size_t DestSize)
int stricomp(const char *s1,const char *s2)
{
#ifdef _WIN_ALL
- return(CompareStringA(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,-1,s2,-1)-2);
+ return CompareStringA(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,-1,s2,-1)-2;
#else
while (toupper(*s1)==toupper(*s2))
{
@@ -194,7 +198,7 @@ uint GetDigits(uint Number)
Number/=10;
Digits++;
}
- return(Digits);
+ return Digits;
}
#endif
@@ -203,8 +207,8 @@ bool LowAscii(const char *Str)
{
for (int I=0;Str[I]!=0;I++)
if ((byte)Str[I]<32 || (byte)Str[I]>127)
- return(false);
- return(true);
+ return false;
+ return true;
}
@@ -213,20 +217,20 @@ bool LowAscii(const wchar *Str)
for (int I=0;Str[I]!=0;I++)
{
// We convert wchar_t to uint just in case if some compiler
- // uses the signed wchar_t.
+ // uses signed wchar_t.
if ((uint)Str[I]<32 || (uint)Str[I]>127)
- return(false);
+ return false;
}
- return(true);
+ return true;
}
int wcsicompc(const wchar *Str1,const wchar *Str2)
{
#if defined(_UNIX)
- return(wcscmp(Str1,Str2));
+ return wcscmp(Str1,Str2);
#else
- return(wcsicomp(Str1,Str2));
+ return wcsicomp(Str1,Str2);
#endif
}
@@ -239,7 +243,7 @@ char* strncpyz(char *dest, const char *src, size_t maxlen)
strncpy(dest,src,maxlen-1);
dest[maxlen-1]=0;
}
- return(dest);
+ return dest;
}
@@ -323,7 +327,7 @@ const wchar* GetWide(const char *Src)
wchar *Str=StrTable[StrNum];
CharToWide(Src,Str,MaxLength);
Str[MaxLength-1]=0;
- return(Str);
+ return Str;
}
@@ -398,14 +402,3 @@ void PrintfPrepareFmt(const wchar *Org,wchar *Cvt,size_t MaxSize)
Cvt[Dest]=0;
}
#endif
-
-
-bool GetPassword(PASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
-{
-#ifdef SILENT
- return false;
-#else
- return GetConsolePassword(Type,FileName,Password);
-#endif
-}
-
diff --git a/src/thirdparty/unrar/strfn.hpp b/src/thirdparty/unrar/strfn.hpp
index fae2c93a6..eae67747c 100644
--- a/src/thirdparty/unrar/strfn.hpp
+++ b/src/thirdparty/unrar/strfn.hpp
@@ -42,7 +42,4 @@ const wchar* GetCmdParam(const wchar *CmdLine,wchar *Param,size_t MaxSize);
void PrintfPrepareFmt(const wchar *Org,wchar *Cvt,size_t MaxSize);
#endif
-enum PASSWORD_TYPE {PASSWORD_GLOBAL,PASSWORD_FILE,PASSWORD_ARCHIVE};
-bool GetPassword(PASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
-
#endif
diff --git a/src/thirdparty/unrar/suballoc.cpp b/src/thirdparty/unrar/suballoc.cpp
index 4a5c22a2e..4bc07bf9d 100644
--- a/src/thirdparty/unrar/suballoc.cpp
+++ b/src/thirdparty/unrar/suballoc.cpp
@@ -5,6 +5,9 @@
* Contents: memory allocation routines *
****************************************************************************/
+static const uint UNIT_SIZE=Max(sizeof(RARPPM_CONTEXT),sizeof(RARPPM_MEM_BLK));
+static const uint FIXED_UNIT_SIZE=12;
+
SubAllocator::SubAllocator()
{
Clean();
@@ -41,11 +44,11 @@ inline uint SubAllocator::U2B(int NU)
-// Calculate RAR_MEM_BLK+Items address. Real RAR_MEM_BLK size must be
-// equal to UNIT_SIZE, so we cannot just add Items to RAR_MEM_BLK address.
-inline RAR_MEM_BLK* SubAllocator::MBPtr(RAR_MEM_BLK *BasePtr,int Items)
+// Calculate RARPPM_MEM_BLK+Items address. Real RARPPM_MEM_BLK size must be
+// equal to UNIT_SIZE, so we cannot just add Items to RARPPM_MEM_BLK address.
+inline RARPPM_MEM_BLK* SubAllocator::MBPtr(RARPPM_MEM_BLK *BasePtr,int Items)
{
- return((RAR_MEM_BLK*)( ((byte *)(BasePtr))+U2B(Items) ));
+ return((RARPPM_MEM_BLK*)( ((byte *)(BasePtr))+U2B(Items) ));
}
@@ -109,7 +112,7 @@ void SubAllocator::InitSubAllocator()
pText=HeapStart;
// Original algorithm operates with 12 byte FIXED_UNIT_SIZE, but actual
- // size of RAR_MEM_BLK and PPM_CONTEXT structures can exceed this value
+ // size of RARPPM_MEM_BLK and RARPPM_CONTEXT structures can exceed this value
// because of alignment and larger pointer fields size.
// So we define UNIT_SIZE for this larger size and adjust memory
// pointers accordingly.
@@ -166,14 +169,14 @@ void SubAllocator::InitSubAllocator()
inline void SubAllocator::GlueFreeBlocks()
{
- RAR_MEM_BLK s0, * p, * p1;
+ RARPPM_MEM_BLK s0, * p, * p1;
int i, k, sz;
if (LoUnit != HiUnit)
*LoUnit=0;
for (i=0, s0.next=s0.prev=&s0;i < N_INDEXES;i++)
while ( FreeList[i].next )
{
- p=(RAR_MEM_BLK*)RemoveNode(i);
+ p=(RARPPM_MEM_BLK*)RemoveNode(i);
p->insertAt(&s0);
p->Stamp=0xFFFF;
p->NU=Indx2Units[i];
diff --git a/src/thirdparty/unrar/suballoc.hpp b/src/thirdparty/unrar/suballoc.hpp
index 474ee5920..0280289cf 100644
--- a/src/thirdparty/unrar/suballoc.hpp
+++ b/src/thirdparty/unrar/suballoc.hpp
@@ -7,24 +7,21 @@
#if !defined(_SUBALLOC_H_)
#define _SUBALLOC_H_
-const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
-const int N_INDEXES=N1+N2+N3+N4;
-
-#if defined(__GNUC__) && !defined(STRICT_ALIGNMENT_REQUIRED)
-#define _PACK_ATTR __attribute__ ((packed))
+#if defined(__GNUC__) && defined(ALLOW_MISALIGNED)
+#define RARPPM_PACK_ATTR __attribute__ ((packed))
#else
-#define _PACK_ATTR
+#define RARPPM_PACK_ATTR
#endif /* defined(__GNUC__) */
-#ifndef STRICT_ALIGNMENT_REQUIRED
+#ifdef ALLOW_MISALIGNED
#pragma pack(1)
#endif
-struct RAR_MEM_BLK
+struct RARPPM_MEM_BLK
{
ushort Stamp, NU;
- RAR_MEM_BLK* next, * prev;
- void insertAt(RAR_MEM_BLK* p)
+ RARPPM_MEM_BLK* next, * prev;
+ void insertAt(RARPPM_MEM_BLK* p)
{
next=(prev=p)->next;
p->next=next->prev=this;
@@ -34,9 +31,9 @@ struct RAR_MEM_BLK
prev->next=next;
next->prev=prev;
}
-} _PACK_ATTR;
+} RARPPM_PACK_ATTR;
-#ifndef STRICT_ALIGNMENT_REQUIRED
+#ifdef ALLOW_MISALIGNED
#ifdef _AIX
#pragma pack(pop)
#else
@@ -45,14 +42,17 @@ struct RAR_MEM_BLK
#endif
-struct RAR_NODE
-{
- RAR_NODE* next;
-};
-
class SubAllocator
{
private:
+ static const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
+ static const int N_INDEXES=N1+N2+N3+N4;
+
+ struct RAR_NODE
+ {
+ RAR_NODE* next;
+ };
+
inline void InsertNode(void* p,int indx);
inline void* RemoveNode(int indx);
inline uint U2B(int NU);
@@ -60,7 +60,7 @@ class SubAllocator
uint GetUsedMemory();
inline void GlueFreeBlocks();
void* AllocUnitsRare(int indx);
- inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,int Items);
+ inline RARPPM_MEM_BLK* MBPtr(RARPPM_MEM_BLK *BasePtr,int Items);
long SubAllocatorSize;
byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
diff --git a/src/thirdparty/unrar/threadmisc.cpp b/src/thirdparty/unrar/threadmisc.cpp
index d35f956a7..90133f983 100644
--- a/src/thirdparty/unrar/threadmisc.cpp
+++ b/src/thirdparty/unrar/threadmisc.cpp
@@ -2,18 +2,75 @@
static ThreadPool *GlobalPool=NULL;
static uint GlobalPoolUseCount=0;
+static inline bool CriticalSectionCreate(CRITSECT_HANDLE *CritSection)
+{
+#ifdef _WIN_ALL
+ InitializeCriticalSection(CritSection);
+ return true;
+#elif defined(_UNIX)
+ return pthread_mutex_init(CritSection,NULL)==0;
+#endif
+}
+
+
+static inline void CriticalSectionDelete(CRITSECT_HANDLE *CritSection)
+{
+#ifdef _WIN_ALL
+ DeleteCriticalSection(CritSection);
+#elif defined(_UNIX)
+ pthread_mutex_destroy(CritSection);
+#endif
+}
+
+
+static inline void CriticalSectionStart(CRITSECT_HANDLE *CritSection)
+{
+#ifdef _WIN_ALL
+ EnterCriticalSection(CritSection);
+#elif defined(_UNIX)
+ pthread_mutex_lock(CritSection);
+#endif
+}
+
+
+static inline void CriticalSectionEnd(CRITSECT_HANDLE *CritSection)
+{
+#ifdef _WIN_ALL
+ LeaveCriticalSection(CritSection);
+#elif defined(_UNIX)
+ pthread_mutex_unlock(CritSection);
+#endif
+}
+
+
+static struct GlobalPoolCreateSync
+{
+ CRITSECT_HANDLE CritSection;
+ GlobalPoolCreateSync() { CriticalSectionCreate(&CritSection); }
+ ~GlobalPoolCreateSync() { CriticalSectionDelete(&CritSection); }
+} PoolCreateSync;
+
+
ThreadPool* CreateThreadPool()
{
+ CriticalSectionStart(&PoolCreateSync.CritSection);
+
if (GlobalPoolUseCount++ == 0)
GlobalPool=new ThreadPool(MaxPoolThreads);
+
+ CriticalSectionEnd(&PoolCreateSync.CritSection);
return GlobalPool;
}
void DestroyThreadPool(ThreadPool *Pool)
{
+ CriticalSectionStart(&PoolCreateSync.CritSection);
+
if (Pool!=NULL && Pool==GlobalPool && GlobalPoolUseCount > 0 && --GlobalPoolUseCount == 0)
delete GlobalPool;
+
+ CriticalSectionEnd(&PoolCreateSync.CritSection);
}
@@ -59,26 +116,6 @@ static void ThreadClose(THREAD_HANDLE hThread)
}
-static inline void CriticalSectionStart(CRITSECT_HANDLE *CritSection)
-{
-#ifdef _WIN_ALL
- EnterCriticalSection(CritSection);
-#elif defined(_UNIX)
- pthread_mutex_lock(CritSection);
-#endif
-}
-
-
-static inline void CriticalSectionEnd(CRITSECT_HANDLE *CritSection)
-{
-#ifdef _WIN_ALL
- LeaveCriticalSection(CritSection);
-#elif defined(_UNIX)
- pthread_mutex_unlock(CritSection);
-#endif
-}
-
-
#ifdef _WIN_ALL
static void CWaitForSingleObject(HANDLE hHandle)
{
diff --git a/src/thirdparty/unrar/threadpool.cpp b/src/thirdparty/unrar/threadpool.cpp
index 6c62e327b..5bff0201e 100644
--- a/src/thirdparty/unrar/threadpool.cpp
+++ b/src/thirdparty/unrar/threadpool.cpp
@@ -22,17 +22,15 @@ ThreadPool::ThreadPool(uint MaxThreads)
Closing=false;
- bool Success;
+ bool Success = CriticalSectionCreate(&CritSection);
#ifdef _WIN_ALL
QueuedTasksCnt=CreateSemaphore(NULL,0,ASIZE(TaskQueue),NULL);
NoneActive=CreateEvent(NULL,TRUE,TRUE,NULL);
- InitializeCriticalSection(&CritSection);
- Success=QueuedTasksCnt!=NULL && NoneActive!=NULL;
+ Success=Success && QueuedTasksCnt!=NULL && NoneActive!=NULL;
#elif defined(_UNIX)
AnyActive = false;
QueuedTasksCnt = 0;
- Success=pthread_mutex_init(&CritSection,NULL)==0 &&
- pthread_cond_init(&AnyActiveCond,NULL)==0 &&
+ Success=Success && pthread_cond_init(&AnyActiveCond,NULL)==0 &&
pthread_mutex_init(&AnyActiveMutex,NULL)==0 &&
pthread_cond_init(&QueuedTasksCntCond,NULL)==0 &&
pthread_mutex_init(&QueuedTasksCntMutex,NULL)==0;
@@ -86,12 +84,11 @@ ThreadPool::~ThreadPool()
ThreadClose(ThreadHandles[I]);
}
+ CriticalSectionDelete(&CritSection);
#ifdef _WIN_ALL
- DeleteCriticalSection(&CritSection);
CloseHandle(QueuedTasksCnt);
CloseHandle(NoneActive);
#elif defined(_UNIX)
- pthread_mutex_destroy(&CritSection);
pthread_cond_destroy(&AnyActiveCond);
pthread_mutex_destroy(&AnyActiveMutex);
pthread_cond_destroy(&QueuedTasksCntCond);
diff --git a/src/thirdparty/unrar/threadpool.hpp b/src/thirdparty/unrar/threadpool.hpp
index 86c0d7450..af3a01cdc 100644
--- a/src/thirdparty/unrar/threadpool.hpp
+++ b/src/thirdparty/unrar/threadpool.hpp
@@ -4,7 +4,11 @@
#ifndef RAR_SMP
const uint MaxPoolThreads=1; // For single threaded version.
#else
+#if defined(_ANDROID)
+const uint MaxPoolThreads=16;
+#else
const uint MaxPoolThreads=32;
+#endif
#ifdef _UNIX
diff --git a/src/thirdparty/unrar/timefn.cpp b/src/thirdparty/unrar/timefn.cpp
index 76712eedb..352a2d3ed 100644
--- a/src/thirdparty/unrar/timefn.cpp
+++ b/src/thirdparty/unrar/timefn.cpp
@@ -1,10 +1,5 @@
#include "rar.hpp"
-RarTime::RarTime()
-{
- Reset();
-}
-
#ifdef _WIN_ALL
RarTime& RarTime::operator =(FILETIME &ft)
{
@@ -46,7 +41,15 @@ void RarTime::GetLocal(RarLocalTime *lt)
FILETIME ft;
GetWin32(&ft);
FILETIME lft;
- FileTimeToLocalFileTime(&ft,&lft);
+
+ // We use these functions instead of FileTimeToLocalFileTime according to
+ // MSDN recommendation: "To account for daylight saving time
+ // when converting a file time to a local time ..."
+ SYSTEMTIME st1,st2;
+ FileTimeToSystemTime(&ft,&st1);
+ SystemTimeToTzSpecificLocalTime(NULL,&st1,&st2);
+ SystemTimeToFileTime(&st2,&lft);
+
SYSTEMTIME st;
FileTimeToSystemTime(&lft,&st);
lt->Year=st.wYear;
@@ -84,7 +87,7 @@ void RarTime::GetLocal(RarLocalTime *lt)
lt->Hour=t->tm_hour;
lt->Minute=t->tm_min;
lt->Second=t->tm_sec;
- lt->Reminder=0;
+ lt->Reminder=itime % 10000000;
lt->wDay=t->tm_wday;
lt->yDay=t->tm_yday;
#endif
@@ -108,8 +111,14 @@ void RarTime::SetLocal(RarLocalTime *lt)
lft.dwLowDateTime+=lt->Reminder;
if (lft.dwLowDateTime<lt->Reminder)
lft.dwHighDateTime++;
+
+ // Reverse procedure which we do in GetLocal.
+ SYSTEMTIME st1,st2;
+ FileTimeToSystemTime(&lft,&st2);
+ TzSpecificLocalTimeToSystemTime(NULL,&st2,&st1);
FILETIME ft;
- LocalFileTimeToFileTime(&lft,&ft);
+ SystemTimeToFileTime(&st1,&ft);
+
*this=ft;
}
else
@@ -125,6 +134,7 @@ void RarTime::SetLocal(RarLocalTime *lt)
t.tm_year=lt->Year-1900;
t.tm_isdst=-1;
*this=mktime(&t);
+ itime+=lt->Reminder;
#endif
}
@@ -275,15 +285,7 @@ void RarTime::SetCurrentTime()
#ifndef SFX_MODULE
const wchar *GetMonthName(int Month)
{
-#ifdef SILENT
- return L"";
-#else
- static MSGID MonthID[]={
- MMonthJan,MMonthFeb,MMonthMar,MMonthApr,MMonthMay,MMonthJun,
- MMonthJul,MMonthAug,MMonthSep,MMonthOct,MMonthNov,MMonthDec
- };
- return St(MonthID[Month]);
-#endif
+ return uiGetMonthName(Month);
}
#endif
diff --git a/src/thirdparty/unrar/timefn.hpp b/src/thirdparty/unrar/timefn.hpp
index 005a72445..f8c914b87 100644
--- a/src/thirdparty/unrar/timefn.hpp
+++ b/src/thirdparty/unrar/timefn.hpp
@@ -22,11 +22,13 @@ class RarTime
// since 01.01.1601.
uint64 itime;
public:
- RarTime();
+ RarTime() {Reset();}
#ifdef _WIN_ALL
+ RarTime(FILETIME &ft) {*this=ft;}
RarTime& operator =(FILETIME &ft);
void GetWin32(FILETIME *ft);
#endif
+ RarTime(time_t ut) {*this=ut;}
RarTime& operator =(time_t ut);
time_t GetUnix();
bool operator == (RarTime &rt) {return itime==rt.itime;}
@@ -45,7 +47,7 @@ class RarTime
void SetAgeText(const wchar *TimeText);
void SetCurrentTime();
void Reset() {itime=0;}
- bool IsSet() {return(itime!=0);}
+ bool IsSet() {return itime!=0;}
};
const wchar *GetMonthName(int Month);
diff --git a/src/thirdparty/unrar/ui.cpp b/src/thirdparty/unrar/ui.cpp
new file mode 100644
index 000000000..d0b34aa80
--- /dev/null
+++ b/src/thirdparty/unrar/ui.cpp
@@ -0,0 +1,15 @@
+#include "rar.hpp"
+
+#include "uicommon.cpp"
+
+#ifdef SILENT
+#include "uisilent.cpp"
+#else
+
+
+
+#ifndef GUI
+#include "uiconsole.cpp"
+#endif
+
+#endif
diff --git a/src/thirdparty/unrar/ui.hpp b/src/thirdparty/unrar/ui.hpp
new file mode 100644
index 000000000..ce054aaa2
--- /dev/null
+++ b/src/thirdparty/unrar/ui.hpp
@@ -0,0 +1,162 @@
+#ifndef _RAR_UI_
+#define _RAR_UI_
+
+// UIERROR_ - error message;
+// UIMSG_ - informational message;
+// UIWAIT_ - message waiting for user confirmation;
+// UIEVENT_ - if simple message is not enough;
+
+enum UIMESSAGE_CODE {
+ UIERROR_SYSERRMSG, UIERROR_GENERALERRMSG, UIERROR_INCERRCOUNT,
+ UIERROR_CHECKSUM, UIERROR_CHECKSUMENC, UIERROR_CHECKSUMPACKED,
+ UIERROR_BADPSW, UIERROR_MEMORY, UIERROR_FILEOPEN, UIERROR_FILECREATE,
+ UIERROR_FILECLOSE, UIERROR_FILESEEK, UIERROR_FILEREAD,
+ UIERROR_FILEWRITE, UIERROR_FILEDELETE, UIERROR_FILERENAME,
+ UIERROR_FILEATTR, UIERROR_FILECOPY, UIERROR_FILECOPYHINT,
+ UIERROR_DIRCREATE, UIERROR_SLINKCREATE, UIERROR_HLINKCREATE,
+ UIERROR_NEEDADMIN, UIERROR_ARCBROKEN, UIERROR_HEADERBROKEN,
+ UIERROR_MHEADERBROKEN, UIERROR_FHEADERBROKEN, UIERROR_SUBHEADERBROKEN,
+ UIERROR_SUBHEADERUNKNOWN, UIERROR_SUBHEADERDATABROKEN, UIERROR_RRDAMAGED,
+ UIERROR_UNKNOWNMETHOD, UIERROR_UNKNOWNENCMETHOD, UIERROR_RENAMING,
+ UIERROR_NEWERRAR, UIERROR_NOTSFX, UIERROR_OLDTOSFX, UIERROR_WRONGSFXVER,
+ UIERROR_ALREADYENC, UIERROR_SYNCSCAN, UIERROR_DICTOUTMEM,
+ UIERROR_USESMALLERDICT, UIERROR_MODIFYUNKNOWN, UIERROR_MODIFYOLD,
+ UIERROR_MODIFYLOCKED, UIERROR_MODIFYVOLUME, UIERROR_NOTVOLUME,
+ UIERROR_NOTFIRSTVOLUME, UIERROR_RECVOLLIMIT, UIERROR_RECVOLDIFFSETS,
+ UIERROR_RECVOLALLEXIST, UIERROR_RECVOLFOUND, UIERROR_RECONSTRUCTING,
+ UIERROR_RECVOLCANNOTFIX, UIERROR_OPFAILED, UIERROR_UNEXPEOF,
+ UIERROR_BADARCHIVE, UIERROR_CMTBROKEN, UIERROR_INVALIDNAME,
+ UIERROR_NEWRARFORMAT, UIERROR_NOTSUPPORTED, UIERROR_ENCRNOTSUPPORTED,
+ UIERROR_RARZIPONLY, UIERROR_REPAIROLDFORMAT, UIERROR_NOFILESREPAIRED,
+ UIERROR_NOFILESTOADD, UIERROR_NOFILESTODELETE, UIERROR_NOFILESTOEXTRACT,
+ UIERROR_MISSINGVOL, UIERROR_NEEDPREVVOL, UIERROR_UNKNOWNEXTRA,
+ UIERROR_NTFSREQUIRED, UIERROR_ZIPVOLSFX, UIERROR_FILERO,
+ UIERROR_TOOLARGESFX, UIERROR_EMAIL, UIERROR_ACLGET, UIERROR_ACLBROKEN,
+ UIERROR_ACLUNKNOWN, UIERROR_ACLSET, UIERROR_STREAMBROKEN,
+ UIERROR_STREAMUNKNOWN, UIERROR_INCOMPATSWITCH, UIERROR_PATHTOOLONG,
+ UIERROR_DIRSCAN, UIERROR_UOWNERGET, UIERROR_UOWNERBROKEN,
+ UIERROR_UOWNERGETOWNERID, UIERROR_UOWNERGETGROUPID, UIERROR_UOWNERSET,
+ UIERROR_ULINKREAD, UIERROR_ULINKEXIST,
+
+ UIMSG_FIRST,
+ UIMSG_STRING, UIMSG_BUILD, UIMSG_RRSEARCH, UIMSG_RRFOUND,
+ UIMSG_RRNOTFOUND, UIMSG_RRDAMAGED, UIMSG_BLOCKSRECOVERED,
+ UIMSG_COPYINGDATA, UIMSG_AREADAMAGED, UIMSG_SECTORDAMAGED,
+ UIMSG_SECTORRECOVERED, UIMSG_SECTORNOTRECOVERED, UIMSG_FOUND,
+ UIMSG_CORRECTINGNAME, UIMSG_BADARCHIVE, UIMSG_CREATING, UIMSG_RENAMING,
+ UIMSG_RECVOLCALCCHECKSUM, UIMSG_RECVOLFOUND, UIMSG_RECVOLMISSING,
+ UIMSG_MISSINGVOL, UIMSG_RECONSTRUCTING, UIMSG_CHECKSUM,
+
+ UIWAIT_FIRST,
+ UIWAIT_DISKFULLNEXT, UIWAIT_FCREATEERROR,
+
+ UIEVENT_FIRST,
+ UIEVENT_SEARCHDUPFILES, UIEVENT_CLEARATTRSTART, UIEVENT_CLEARATTRFILE,
+ UIEVENT_DELADDEDSTART, UIEVENT_DELADDEDFILE, UIEVENT_FILESFOUND,
+ UIEVENT_ERASEDISK, UIEVENT_FILESUMSTART, UIEVENT_FILESUMPROGRESS,
+ UIEVENT_FILESUMEND, UIEVENT_PROTECTSTART, UIEVENT_PROTECTEND,
+ UIEVENT_TESTADDEDSTART, UIEVENT_TESTADDEDEND, UIEVENT_RRTESTING,
+
+};
+
+// Flags for uiAskReplace function.
+enum UIASKREP_FLAGS {
+ UIASKREP_F_NORENAME=1,UIASKREP_F_EXCHSRCDEST=2,UIASKREP_F_SHOWNAMEONLY=4
+};
+
+// Codes returned by uiAskReplace. Note that uiAskReplaceEx returns only
+// UIASKREP_R_REPLACE, UIASKREP_R_SKIP and UIASKREP_R_CANCEL codes.
+enum UIASKREP_RESULT {
+ UIASKREP_R_REPLACE,UIASKREP_R_SKIP,UIASKREP_R_REPLACEALL,UIASKREP_R_SKIPALL,
+ UIASKREP_R_RENAME,UIASKREP_R_RENAMEAUTO,UIASKREP_R_CANCEL,UIASKREP_R_UNUSED
+};
+
+UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
+UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
+
+void uiInit(bool Sound);
+
+
+void uiStartArchiveExtract(bool Extract,const wchar *ArcName);
+bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip);
+void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize);
+void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize);
+
+enum UIPASSWORD_TYPE {UIPASSWORD_GLOBAL,UIPASSWORD_FILE,UIPASSWORD_ARCHIVE};
+bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
+
+enum UIALARM_TYPE {UIALARM_ERROR, UIALARM_INFO, UIALARM_QUESTION};
+void uiAlarm(UIALARM_TYPE Type);
+
+
+bool uiAskNextVolume(wchar *VolName,size_t MaxSize);
+bool uiAskRepeatRead(const wchar *FileName);
+bool uiAskRepeatWrite(const wchar *FileName,bool DiskFull);
+
+#ifndef SFX_MODULE
+const wchar *uiGetMonthName(int Month);
+#endif
+
+
+class uiMsgStore
+{
+ private:
+ static const size_t MAX_MSG = 8;
+ const wchar *Str[MAX_MSG];
+ uint Num[MAX_MSG];
+ uint StrSize,NumSize;
+ UIMESSAGE_CODE Code;
+ public:
+ uiMsgStore(UIMESSAGE_CODE Code)
+ {
+ NumSize=StrSize=0;
+ this->Code=Code;
+ }
+ uiMsgStore& operator << (const wchar *s)
+ {
+ if (StrSize<MAX_MSG)
+ Str[StrSize++]=s;
+ return *this;
+ }
+ uiMsgStore& operator << (uint n)
+ {
+ if (NumSize<MAX_MSG)
+ Num[NumSize++]=n;
+ return *this;
+ }
+
+ void Msg();
+};
+
+
+// Templates recognize usual NULL as integer, not wchar*.
+#define UINULL ((wchar *)NULL)
+
+inline void uiMsg(UIMESSAGE_CODE Code)
+{
+ uiMsgStore Store(Code);
+ Store.Msg();
+}
+
+template<class T1> void uiMsg(UIMESSAGE_CODE Code,T1 a1)
+{
+ uiMsgStore Store(Code);
+ Store<<a1;
+ Store.Msg();
+}
+
+template<class T1,class T2> void uiMsg(UIMESSAGE_CODE Code,T1 a1,T2 a2)
+{
+ uiMsgStore Store(Code);
+ Store<<a1<<a2;
+ Store.Msg();
+}
+
+template<class T1,class T2,class T3> void uiMsg(UIMESSAGE_CODE code,T1 a1,T2 a2,T3 a3)
+{
+ uiMsgStore Store(code);
+ Store<<a1<<a2<<a3;
+ Store.Msg();
+}
+
+#endif
diff --git a/src/thirdparty/unrar/uicommon.cpp b/src/thirdparty/unrar/uicommon.cpp
new file mode 100644
index 000000000..7238c1936
--- /dev/null
+++ b/src/thirdparty/unrar/uicommon.cpp
@@ -0,0 +1,58 @@
+static bool uiSoundEnabled;
+
+void uiInit(bool Sound)
+{
+ uiSoundEnabled = Sound;
+}
+
+
+// Additionally to handling user input, it analyzes and sets command options.
+// Returns only 'replace', 'skip' and 'cancel' codes.
+UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags)
+{
+ if (Cmd->Overwrite==OVERWRITE_NONE)
+ return UIASKREP_R_SKIP;
+
+#if !defined(SFX_MODULE) && !defined(SILENT)
+ // Must be before Cmd->AllYes check or -y switch would override -or.
+ if (Cmd->Overwrite==OVERWRITE_AUTORENAME && GetAutoRenamedName(Name,MaxNameSize))
+ return UIASKREP_R_REPLACE;
+#endif
+
+ // This check must be after OVERWRITE_AUTORENAME processing or -y switch
+ // would override -or.
+ if (Cmd->AllYes || Cmd->Overwrite==OVERWRITE_ALL)
+ return UIASKREP_R_REPLACE;
+
+ wchar NewName[NM];
+ wcsncpyz(NewName,Name,ASIZE(NewName));
+ UIASKREP_RESULT Choice=uiAskReplace(NewName,ASIZE(NewName),FileSize,FileTime,Flags);
+ if (Choice==UIASKREP_R_REPLACEALL)
+ {
+ Cmd->Overwrite=OVERWRITE_ALL;
+ return UIASKREP_R_REPLACE;
+ }
+ if (Choice==UIASKREP_R_SKIPALL)
+ {
+ Cmd->Overwrite=OVERWRITE_NONE;
+ return UIASKREP_R_SKIP;
+ }
+ if (Choice==UIASKREP_R_RENAME)
+ {
+ if (PointToName(NewName)==NewName)
+ SetName(Name,NewName,MaxNameSize);
+ else
+ wcsncpyz(Name,NewName,MaxNameSize);
+ if (FileExist(Name))
+ return uiAskReplaceEx(Cmd,Name,MaxNameSize,FileSize,FileTime,Flags);
+ return UIASKREP_R_REPLACE;
+ }
+#if !defined(SFX_MODULE) && !defined(SILENT)
+ if (Choice==UIASKREP_R_RENAMEAUTO && GetAutoRenamedName(Name,MaxNameSize))
+ {
+ Cmd->Overwrite=OVERWRITE_AUTORENAME;
+ return UIASKREP_R_REPLACE;
+ }
+#endif
+ return Choice;
+}
diff --git a/src/thirdparty/unrar/uiconsole.cpp b/src/thirdparty/unrar/uiconsole.cpp
new file mode 100644
index 000000000..d242cce3d
--- /dev/null
+++ b/src/thirdparty/unrar/uiconsole.cpp
@@ -0,0 +1,366 @@
+// Purely user interface function. Gets and returns user input.
+UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags)
+{
+ bool AllowRename=(Flags & UIASKREP_F_NORENAME)==0;
+ eprintf(St(MFileExists),Name);
+ int Choice=Ask(St(AllowRename ? MYesNoAllRenQ : MYesNoAllQ));
+ switch(Choice)
+ {
+ case 1:
+ return UIASKREP_R_REPLACE;
+ case 2:
+ return UIASKREP_R_SKIP;
+ case 3:
+ return UIASKREP_R_REPLACEALL;
+ case 4:
+ return UIASKREP_R_SKIPALL;
+ }
+ if (AllowRename && Choice==5)
+ {
+ mprintf(St(MAskNewName));
+ if (getwstr(Name,MaxNameSize))
+ return UIASKREP_R_RENAME;
+ else
+ return UIASKREP_R_SKIP; // Process fwgets failure as if user answered 'No'.
+ }
+ return UIASKREP_R_CANCEL;
+}
+
+
+
+
+void uiStartArchiveExtract(bool Extract,const wchar *ArcName)
+{
+ mprintf(St(Extract ? MExtracting : MExtrTest), ArcName);
+}
+
+
+bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip)
+{
+ return true;
+}
+
+
+void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize)
+{
+ int CurPercent=ToPercent(CurSize,TotalSize);
+ mprintf(L"\b\b\b\b%3d%%",CurPercent);
+}
+
+
+void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize)
+{
+ int CurPercent=ToPercent(CurSize,TotalSize);
+ mprintf(L"\b\b\b\b%3d%%",CurPercent);
+}
+
+
+void uiMsgStore::Msg()
+{
+ switch(Code)
+ {
+ case UIERROR_SYSERRMSG:
+ case UIERROR_GENERALERRMSG:
+ Log(NULL,L"\n%ls",Str[0]);
+ break;
+ case UIERROR_CHECKSUM:
+ Log(Str[0],St(MCRCFailed),Str[1]);
+ break;
+ case UIERROR_CHECKSUMENC:
+ Log(Str[0],St(MEncrBadCRC),Str[1]);
+ break;
+ case UIERROR_CHECKSUMPACKED:
+ Log(Str[0],St(MDataBadCRC),Str[1],Str[0]);
+ break;
+ case UIERROR_BADPSW:
+ Log(Str[0],St(MWrongPassword));
+ break;
+ case UIERROR_MEMORY:
+ Log(NULL,St(MErrOutMem));
+ break;
+ case UIERROR_FILEOPEN:
+ Log(Str[0],St(MCannotOpen),Str[1]);
+ break;
+ case UIERROR_FILECREATE:
+ Log(Str[0],St(MCannotCreate),Str[1]);
+ break;
+ case UIERROR_FILECLOSE:
+ Log(NULL,St(MErrFClose),Str[0]);
+ break;
+ case UIERROR_FILESEEK:
+ Log(NULL,St(MErrSeek),Str[0]);
+ break;
+ case UIERROR_FILEREAD:
+ Log(Str[0],St(MErrRead),Str[1]);
+ break;
+ case UIERROR_FILEWRITE:
+ Log(Str[0],St(MErrWrite),Str[1]);
+ break;
+#ifndef SFX_MODULE
+ case UIERROR_FILEDELETE:
+ Log(Str[0],St(MCannotDelete),Str[1]);
+ break;
+ case UIERROR_FILERENAME:
+ Log(Str[0],St(MErrRename),Str[1],Str[2]);
+ break;
+#endif
+ case UIERROR_FILEATTR:
+ Log(Str[0],St(MErrChangeAttr),Str[1]);
+ break;
+ case UIERROR_FILECOPY:
+ Log(Str[0],St(MCopyError),Str[1],Str[2]);
+ break;
+ case UIERROR_FILECOPYHINT:
+ Log(Str[0],St(MCopyErrorHint));
+ break;
+ case UIERROR_DIRCREATE:
+ Log(Str[0],St(MExtrErrMkDir),Str[1]);
+ break;
+ case UIERROR_SLINKCREATE:
+ Log(Str[0],St(MErrCreateLnkS),Str[1]);
+ break;
+ case UIERROR_HLINKCREATE:
+ Log(NULL,St(MErrCreateLnkH),Str[0]);
+ break;
+ case UIERROR_NEEDADMIN:
+ Log(NULL,St(MNeedAdmin));
+ break;
+ case UIERROR_ARCBROKEN:
+ Log(Str[0],St(MErrBrokenArc));
+ break;
+ case UIERROR_HEADERBROKEN:
+ Log(Str[0],St(MHeaderBroken));
+ break;
+ case UIERROR_MHEADERBROKEN:
+ Log(Str[0],St(MMainHeaderBroken));
+ break;
+ case UIERROR_FHEADERBROKEN:
+ Log(Str[0],St(MLogFileHead),Str[1]);
+ break;
+ case UIERROR_SUBHEADERBROKEN:
+ Log(Str[0],St(MSubHeadCorrupt));
+ break;
+ case UIERROR_SUBHEADERUNKNOWN:
+ Log(Str[0],St(MSubHeadUnknown));
+ break;
+ case UIERROR_SUBHEADERDATABROKEN:
+ Log(Str[0],St(MSubHeadDataCRC),Str[1]);
+ break;
+ case UIERROR_RRDAMAGED:
+ Log(Str[0],St(MRRDamaged));
+ break;
+ case UIERROR_UNKNOWNMETHOD:
+ Log(Str[0],St(MUnknownMeth),Str[1]);
+ break;
+ case UIERROR_UNKNOWNENCMETHOD:
+ Log(Str[0],St(MUnkEncMethod),Str[1]);
+ break;
+#ifndef SFX_MODULE
+ case UIERROR_RENAMING:
+ Log(Str[0],St(MRenaming),Str[1],Str[2]);
+ break;
+ case UIERROR_NEWERRAR:
+ Log(Str[0],St(MNewerRAR));
+ break;
+#endif
+ case UIERROR_RECVOLDIFFSETS:
+ Log(NULL,St(MRecVolDiffSets),Str[0],Str[1]);
+ break;
+ case UIERROR_RECVOLALLEXIST:
+ mprintf(St(MRecVolAllExist));
+ break;
+ case UIERROR_RECONSTRUCTING:
+ mprintf(St(MReconstructing));
+ break;
+ case UIERROR_RECVOLCANNOTFIX:
+ mprintf(St(MRecVolCannotFix));
+ break;
+ case UIERROR_UNEXPEOF:
+ Log(Str[0],St(MLogUnexpEOF));
+ break;
+ case UIERROR_BADARCHIVE:
+ Log(Str[0],St(MBadArc),Str[0]);
+ break;
+ case UIERROR_CMTBROKEN:
+ Log(Str[0],St(MLogCommBrk));
+ break;
+ case UIERROR_INVALIDNAME:
+ Log(Str[0],St(MInvalidName),Str[1]);
+ break;
+#ifndef SFX_MODULE
+ case UIERROR_NEWRARFORMAT:
+ Log(Str[0],St(MNewRarFormat));
+ break;
+#endif
+ case UIERROR_NOFILESTOEXTRACT:
+ mprintf(St(MExtrNoFiles));
+ break;
+ case UIERROR_MISSINGVOL:
+ Log(Str[0],St(MAbsNextVol),Str[0]);
+ break;
+#ifndef SFX_MODULE
+ case UIERROR_NEEDPREVVOL:
+ Log(Str[0],St(MUnpCannotMerge),Str[1]);
+ break;
+ case UIERROR_UNKNOWNEXTRA:
+ Log(Str[0],St(MUnknownExtra),Str[1]);
+ break;
+#endif
+#if !defined(SFX_MODULE) && defined(_WIN_ALL)
+ case UIERROR_NTFSREQUIRED:
+ Log(NULL,St(MNTFSRequired),Str[0]);
+ break;
+#endif
+#if !defined(SFX_MODULE) && defined(_WIN_ALL)
+ case UIERROR_ACLBROKEN:
+ Log(Str[0],St(MACLBroken),Str[1]);
+ break;
+ case UIERROR_ACLUNKNOWN:
+ Log(Str[0],St(MACLUnknown),Str[1]);
+ break;
+ case UIERROR_ACLSET:
+ Log(Str[0],St(MACLSetError),Str[1]);
+ break;
+ case UIERROR_STREAMBROKEN:
+ Log(Str[0],St(MStreamBroken),Str[1]);
+ break;
+ case UIERROR_STREAMUNKNOWN:
+ Log(Str[0],St(MStreamUnknown),Str[1]);
+ break;
+#endif
+ case UIERROR_INCOMPATSWITCH:
+ mprintf(St(MIncompatSwitch),Str[0],Num[0]);
+ break;
+ case UIERROR_PATHTOOLONG:
+ Log(NULL,L"\n%ls%ls%ls",Str[0],Str[1],Str[2]);
+ Log(NULL,St(MPathTooLong));
+ break;
+#ifndef SFX_MODULE
+ case UIERROR_DIRSCAN:
+ Log(NULL,St(MScanError),Str[0]);
+ break;
+#endif
+ case UIERROR_UOWNERBROKEN:
+ Log(Str[0],St(MOwnersBroken),Str[1]);
+ break;
+ case UIERROR_UOWNERGETOWNERID:
+ Log(Str[0],St(MErrGetOwnerID),Str[1]);
+ break;
+ case UIERROR_UOWNERGETGROUPID:
+ Log(Str[0],St(MErrGetGroupID),Str[1]);
+ break;
+ case UIERROR_UOWNERSET:
+ Log(Str[0],St(MSetOwnersError),Str[1]);
+ break;
+ case UIERROR_ULINKREAD:
+ Log(NULL,St(MErrLnkRead),Str[0]);
+ break;
+ case UIERROR_ULINKEXIST:
+ Log(NULL,St(MSymLinkExists),Str[0]);
+ break;
+
+
+#ifndef SFX_MODULE
+ case UIMSG_STRING:
+ mprintf(L"\n%s",Str[0]);
+ break;
+#endif
+ case UIMSG_CORRECTINGNAME:
+ Log(Str[0],St(MCorrectingName));
+ break;
+ case UIMSG_BADARCHIVE:
+ mprintf(St(MBadArc),Str[0]);
+ break;
+ case UIMSG_CREATING:
+ mprintf(St(MCreating),Str[0]);
+ break;
+ case UIMSG_RENAMING:
+ mprintf(St(MRenaming),Str[0],Str[1]);
+ break;
+ case UIMSG_RECVOLCALCCHECKSUM:
+ mprintf(St(MCalcCRCAllVol));
+ break;
+ case UIMSG_RECVOLFOUND:
+ mprintf(St(MRecVolFound),Num[0]);
+ break;
+ case UIMSG_RECVOLMISSING:
+ mprintf(St(MRecVolMissing),Num[0]);
+ break;
+ case UIMSG_MISSINGVOL:
+ mprintf(St(MAbsNextVol),Str[0]);
+ break;
+ case UIMSG_RECONSTRUCTING:
+ mprintf(St(MReconstructing));
+ break;
+ case UIMSG_CHECKSUM:
+ mprintf(St(MCRCFailed),Str[0]);
+ break;
+
+
+
+
+ case UIEVENT_RRTESTING:
+ mprintf(L"%s ",St(MTestingRR));
+ break;
+ }
+}
+
+
+bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
+{
+ return GetConsolePassword(Type,FileName,Password);
+}
+
+
+void uiAlarm(UIALARM_TYPE Type)
+{
+ if (uiSoundEnabled)
+ {
+ static clock_t LastTime=clock();
+ if ((clock()-LastTime)/CLOCKS_PER_SEC>5)
+ {
+#ifdef _WIN_ALL
+ MessageBeep(-1);
+#else
+ putwchar('\007');
+#endif
+ }
+ }
+}
+
+
+
+
+bool uiAskNextVolume(wchar *VolName,size_t MaxSize)
+{
+ eprintf(St(MAskNextVol),VolName);
+ return Ask(St(MContinueQuit))!=2;
+}
+
+
+bool uiAskRepeatRead(const wchar *FileName)
+{
+ mprintf(L"\n");
+ Log(NULL,St(MErrRead),FileName);
+ return Ask(St(MRetryAbort))==1;
+}
+
+
+bool uiAskRepeatWrite(const wchar *FileName,bool DiskFull)
+{
+ mprintf(L"\n");
+ Log(NULL,St(DiskFull ? MNotEnoughDisk:MErrWrite),FileName);
+ return Ask(St(MRetryAbort))==1;
+}
+
+
+#ifndef SFX_MODULE
+const wchar *uiGetMonthName(int Month)
+{
+ static MSGID MonthID[12]={
+ MMonthJan,MMonthFeb,MMonthMar,MMonthApr,MMonthMay,MMonthJun,
+ MMonthJul,MMonthAug,MMonthSep,MMonthOct,MMonthNov,MMonthDec
+ };
+ return St(MonthID[Month]);
+}
+#endif
diff --git a/src/thirdparty/unrar/uisilent.cpp b/src/thirdparty/unrar/uisilent.cpp
new file mode 100644
index 000000000..87e563856
--- /dev/null
+++ b/src/thirdparty/unrar/uisilent.cpp
@@ -0,0 +1,63 @@
+// Purely user interface function. Gets and returns user input.
+UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags)
+{
+ return UIASKREP_R_REPLACE;
+}
+
+
+
+
+void uiStartArchiveExtract(bool Extract,const wchar *ArcName)
+{
+}
+
+
+bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip)
+{
+ return true;
+}
+
+
+void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize)
+{
+}
+
+
+void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize)
+{
+}
+
+
+void uiMsgStore::Msg()
+{
+}
+
+
+bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
+{
+ return false;
+}
+
+
+void uiAlarm(UIALARM_TYPE Type)
+{
+}
+
+
+bool uiIsAborted()
+{
+ return false;
+}
+
+
+void uiGiveTick()
+{
+}
+
+
+#ifndef SFX_MODULE
+const wchar *uiGetMonthName(int Month)
+{
+ return L"";
+}
+#endif
diff --git a/src/thirdparty/unrar/ulinks.cpp b/src/thirdparty/unrar/ulinks.cpp
index fd82840c4..cbbd8ad1c 100644
--- a/src/thirdparty/unrar/ulinks.cpp
+++ b/src/thirdparty/unrar/ulinks.cpp
@@ -9,10 +9,10 @@ static bool UnixSymlink(const char *Target,const wchar *LinkName)
if (symlink(Target,LinkNameA)==-1) // Error.
{
if (errno==EEXIST)
- Log(NULL,St(MSymLinkExists),LinkName);
+ uiMsg(UIERROR_ULINKEXIST,LinkName);
else
{
- Log(NULL,St(MErrCreateLnkS),LinkName);
+ uiMsg(UIERROR_SLINKCREATE,UINULL,LinkName);
ErrHandler.SetErrorCode(RARX_WARNING);
}
return false;
diff --git a/src/thirdparty/unrar/unicode.cpp b/src/thirdparty/unrar/unicode.cpp
index a6b0907a4..cff2358d0 100644
--- a/src/thirdparty/unrar/unicode.cpp
+++ b/src/thirdparty/unrar/unicode.cpp
@@ -26,13 +26,17 @@ bool WideToChar(const wchar *Src,char *Dest,size_t DestSize)
if (WideCharToMultiByte(CP_ACP,0,Src,-1,Dest,(int)DestSize,NULL,NULL)==0)
RetCode=false;
-#elif defined(_APPLE)
+// wcstombs is broken in Android NDK r9.
+#elif defined(_APPLE) || defined(_ANDROID)
WideToUtf(Src,Dest,DestSize);
#elif defined(MBFUNCTIONS)
if (!WideToCharMap(Src,Dest,DestSize,RetCode))
{
- size_t ResultingSize=wcstombs(Dest,Src,DestSize);
+ mbstate_t ps; // Use thread safe external state based functions.
+ memset (&ps, 0, sizeof(ps));
+ const wchar *SrcParam=Src; // wcsrtombs can change the pointer.
+ size_t ResultingSize=wcsrtombs(Dest,&SrcParam,DestSize,&ps);
if (ResultingSize==(size_t)-1)
RetCode=false;
if (ResultingSize==0 && *Src!=0)
@@ -69,11 +73,15 @@ bool CharToWide(const char *Src,wchar *Dest,size_t DestSize)
if (MultiByteToWideChar(CP_ACP,0,Src,-1,Dest,(int)DestSize)==0)
RetCode=false;
-#elif defined(_APPLE)
+// mbstowcs is broken in Android NDK r9.
+#elif defined(_APPLE) || defined(_ANDROID)
UtfToWide(Src,Dest,DestSize);
#elif defined(MBFUNCTIONS)
- size_t ResultingSize=mbstowcs(Dest,Src,DestSize);
+ mbstate_t ps;
+ memset (&ps, 0, sizeof(ps));
+ const char *SrcParam=Src; // mbsrtowcs can change the pointer.
+ size_t ResultingSize=mbsrtowcs(Dest,&SrcParam,DestSize,&ps);
if (ResultingSize==(size_t)-1)
RetCode=false;
if (ResultingSize==0 && *Src!=0)
@@ -81,7 +89,6 @@ bool CharToWide(const char *Src,wchar *Dest,size_t DestSize)
if (RetCode==false && DestSize>1)
CharToWideMap(Src,Dest,DestSize,RetCode);
-
#else
for (int I=0;I<DestSize;I++)
{
@@ -103,7 +110,7 @@ bool CharToWide(const char *Src,wchar *Dest,size_t DestSize)
}
-#if defined(_UNIX) && defined(MBFUNCTIONS)
+#if defined(_UNIX) && defined(MBFUNCTIONS) && !defined(_ANDROID)
// Convert and restore mapped inconvertible Unicode characters.
// We use it for extended ASCII names in Unix.
bool WideToCharMap(const wchar *Src,char *Dest,size_t DestSize,bool &Success)
@@ -133,12 +140,13 @@ bool WideToCharMap(const wchar *Src,char *Dest,size_t DestSize,bool &Success)
Dest[DestPos++]=char(uint(Src[SrcPos++])-MapAreaStart);
else
{
- ignore_result( wctomb(NULL,0) ); // Reset shift state.
- if (wctomb(Dest+DestPos,Src[SrcPos])==-1)
+ mbstate_t ps;
+ memset(&ps,0,sizeof(ps));
+ if (wcrtomb(Dest+DestPos,Src[SrcPos],&ps)==-1)
Success=false;
SrcPos++;
- ignore_result( mblen(NULL,0) ); // Reset shift state.
- int Length=mblen(Dest+DestPos,MB_CUR_MAX);
+ memset(&ps,0,sizeof(ps));
+ int Length=mbrlen(Dest+DestPos,MB_CUR_MAX,&ps);
DestPos+=Max(Length,1);
}
}
@@ -147,7 +155,7 @@ bool WideToCharMap(const wchar *Src,char *Dest,size_t DestSize,bool &Success)
#endif
-#if defined(_UNIX) && defined(MBFUNCTIONS)
+#if defined(_UNIX) && defined(MBFUNCTIONS) && !defined(_ANDROID)
// Convert and map inconvertible Unicode characters.
// We use it for extended ASCII names in Unix.
void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)
@@ -166,8 +174,9 @@ void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)
Success=true;
break;
}
- ignore_result( mbtowc(NULL,NULL,0) ); // Reset shift state.
- if (mbtowc(Dest+DestPos,Src+SrcPos,MB_CUR_MAX)==-1)
+ mbstate_t ps;
+ memset(&ps,0,sizeof(ps));
+ if (mbrtowc(Dest+DestPos,Src+SrcPos,MB_CUR_MAX,&ps)==-1)
{
// For security reasons we do not want to map low ASCII characters,
// so we do not have additional .. and path separator codes.
@@ -187,8 +196,8 @@ void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)
}
else
{
- ignore_result( mblen(NULL,0) ); // Reset shift state.
- int Length=mblen(Src+SrcPos,MB_CUR_MAX);
+ memset(&ps,0,sizeof(ps));
+ int Length=mbrlen(Src+SrcPos,MB_CUR_MAX,&ps);
SrcPos+=Max(Length,1);
DestPos++;
}
@@ -373,14 +382,18 @@ int wcsicomp(const wchar *s1,const wchar *s2)
#ifdef _WIN_ALL
return CompareStringW(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,-1,s2,-1)-2;
#else
- while (towupper(*s1)==towupper(*s2))
+ while (true)
{
+ wchar u1 = towupper(*s1);
+ wchar u2 = towupper(*s2);
+ if (u1 != u2)
+ return u1 < u2 ? -1 : 1;
if (*s1==0)
- return 0;
+ break;
s1++;
s2++;
}
- return s1 < s2 ? -1 : 1;
+ return 0;
#endif
}
@@ -393,27 +406,45 @@ int wcsnicomp(const wchar *s1,const wchar *s2,size_t n)
// to real string length.
size_t l1=Min(wcslen(s1)+1,n);
size_t l2=Min(wcslen(s2)+1,n);
- return(CompareStringW(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,(int)l1,s2,(int)l2)-2);
+ return CompareStringW(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,(int)l1,s2,(int)l2)-2;
#else
if (n==0)
return 0;
- while (towupper(*s1)==towupper(*s2))
+ while (true)
{
+ wchar u1 = towupper(*s1);
+ wchar u2 = towupper(*s2);
+ if (u1 != u2)
+ return u1 < u2 ? -1 : 1;
if (*s1==0 || --n==0)
- return 0;
+ break;
s1++;
s2++;
}
- return s1 < s2 ? -1 : 1;
+ return 0;
#endif
}
+const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search)
+{
+ for (size_t i=0;str[i]!=0;i++)
+ for (size_t j=0;;j++)
+ {
+ if (search[j]==0)
+ return str+i;
+ if (towlower(str[i+j])!=towlower(search[j]))
+ break;
+ }
+ return NULL;
+}
+
+
#ifndef SFX_MODULE
wchar* wcslower(wchar *s)
{
#ifdef _WIN_ALL
- CharLowerW(s);
+ CharLower(s);
#else
for (wchar *c=s;*c!=0;c++)
*c=towlower(*c);
@@ -427,7 +458,7 @@ wchar* wcslower(wchar *s)
wchar* wcsupper(wchar *s)
{
#ifdef _WIN_ALL
- CharUpperW(s);
+ CharUpper(s);
#else
for (wchar *c=s;*c!=0;c++)
*c=towupper(*c);
@@ -437,23 +468,17 @@ wchar* wcsupper(wchar *s)
#endif
+
+
int toupperw(int ch)
{
-#ifdef _WIN_ALL
- return (int)CharUpperW((wchar *)ch);
-#else
return towupper(ch);
-#endif
}
int tolowerw(int ch)
{
-#ifdef _WIN_ALL
- return (int)CharLowerW((wchar *)ch);
-#else
return towlower(ch);
-#endif
}
diff --git a/src/thirdparty/unrar/unicode.hpp b/src/thirdparty/unrar/unicode.hpp
index 0e0bf963c..29eeb0edd 100644
--- a/src/thirdparty/unrar/unicode.hpp
+++ b/src/thirdparty/unrar/unicode.hpp
@@ -15,8 +15,11 @@ bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize);
int wcsicomp(const wchar *s1,const wchar *s2);
int wcsnicomp(const wchar *s1,const wchar *s2,size_t n);
+const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search);
+#ifndef SFX_MODULE
wchar* wcslower(wchar *s);
wchar* wcsupper(wchar *s);
+#endif
int toupperw(int ch);
int tolowerw(int ch);
uint atoiw(const wchar *s);
diff --git a/src/thirdparty/unrar/unpack.cpp b/src/thirdparty/unrar/unpack.cpp
index af82ff13e..be9ff7da6 100644
--- a/src/thirdparty/unrar/unpack.cpp
+++ b/src/thirdparty/unrar/unpack.cpp
@@ -87,15 +87,19 @@ void Unpack::Init(size_t WinSize,bool Solid)
// extra cautious, we still handle the solid window grow case below.
bool Grow=Solid && (Window!=NULL || Fragmented);
- byte *NewWindow=(byte *)malloc(WinSize);
-
- // We do not handle growth for fragmented window now.
- if (Grow && (NewWindow==NULL || Fragmented))
+ // We do not handle growth for existing fragmented window.
+ if (Grow && Fragmented)
throw std::bad_alloc();
+ byte *NewWindow=(byte *)malloc(WinSize);
+
if (NewWindow==NULL)
- if (WinSize<0x1000000) // Exclude RAR4 and small dictionaries.
+ if (Grow || WinSize<0x1000000)
+ {
+ // We do not support growth for new fragmented window.
+ // Also exclude RAR4 and small dictionaries.
throw std::bad_alloc();
+ }
else
{
FragWindow.Init(WinSize);
diff --git a/src/thirdparty/unrar/unpack.hpp b/src/thirdparty/unrar/unpack.hpp
index 2cd739722..2907e8c80 100644
--- a/src/thirdparty/unrar/unpack.hpp
+++ b/src/thirdparty/unrar/unpack.hpp
@@ -14,7 +14,7 @@
#define UNPACK_MAX_WRITE 0x400000
// Decode compressed bit fields to alphabet numbers.
-struct DecodeTable
+struct DecodeTable:PackDef
{
// Real size of DecodeNum table.
uint MaxNum;
@@ -184,7 +184,7 @@ class FragmentedWindow
};
-class Unpack
+class Unpack:PackDef
{
private:
diff --git a/src/thirdparty/unrar/unpack50.cpp b/src/thirdparty/unrar/unpack50.cpp
index 6132409b9..1b184c4f1 100644
--- a/src/thirdparty/unrar/unpack50.cpp
+++ b/src/thirdparty/unrar/unpack50.cpp
@@ -233,13 +233,19 @@ bool Unpack::UnpReadBuf()
}
else
DataSize=ReadTop;
- int ReadCode=UnpIO->UnpRead(Inp.InBuf+DataSize,BitInput::MAX_SIZE-DataSize);
- if (ReadCode>0)
+ int ReadCode=0;
+ if (BitInput::MAX_SIZE!=DataSize)
+ ReadCode=UnpIO->UnpRead(Inp.InBuf+DataSize,BitInput::MAX_SIZE-DataSize);
+ if (ReadCode>0) // Can be also -1.
ReadTop+=ReadCode;
ReadBorder=ReadTop-30;
BlockHeader.BlockStart=Inp.InAddr;
if (BlockHeader.BlockSize!=-1) // '-1' means not defined yet.
+ {
+ // We may need to quit from main extraction loop and read new block header
+ // and trees earlier than data in input buffer ends.
ReadBorder=Min(ReadBorder,BlockHeader.BlockStart+BlockHeader.BlockSize-1);
+ }
return ReadCode!=-1;
}
@@ -420,7 +426,7 @@ void Unpack::FilterItanium_SetBits(byte *Data,uint BitField,int BitPos,int BitCo
inline uint GetFiltData32(byte *Data)
{
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED) || !defined(PRESENT_INT32)
uint Value=GET_UINT32((uint)Data[0]|((uint)Data[1]<<8)|((uint)Data[2]<<16)|((uint)Data[3]<<24));
#else
uint Value=GET_UINT32(*(uint32 *)Data);
@@ -431,7 +437,7 @@ inline uint GetFiltData32(byte *Data)
inline void SetFiltData32(byte *Data,uint Value)
{
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
+#if defined(BIG_ENDIAN) || !defined(ALLOW_MISALIGNED) || !defined(PRESENT_INT32)
Data[0]=(byte)Value;
Data[1]=(byte)(Value>>8);
Data[2]=(byte)(Value>>16);
diff --git a/src/thirdparty/unrar/unpack50mt.cpp b/src/thirdparty/unrar/unpack50mt.cpp
index 5a0d7d2a1..98891ba15 100644
--- a/src/thirdparty/unrar/unpack50mt.cpp
+++ b/src/thirdparty/unrar/unpack50mt.cpp
@@ -457,7 +457,7 @@ bool Unpack::ProcessDecoded(UnpackThreadData &D)
if (Item->Type==UNPDT_LITERAL)
{
-#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT)
+#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32) && defined(ALLOW_MISALIGNED)
if (Item->Length==3 && UnpPtr<MaxWinSize-4)
{
*(uint32 *)(Window+UnpPtr)=*(uint32 *)Item->Literal;
diff --git a/src/thirdparty/unrar/unrar.vcxproj b/src/thirdparty/unrar/unrar.vcxproj
index 71d75b73f..3a0aafb89 100644
--- a/src/thirdparty/unrar/unrar.vcxproj
+++ b/src/thirdparty/unrar/unrar.vcxproj
@@ -145,6 +145,7 @@
<ClCompile Include="system.cpp" />
<ClCompile Include="threadpool.cpp" />
<ClCompile Include="timefn.cpp" />
+ <ClCompile Include="ui.cpp" />
<ClCompile Include="unicode.cpp" />
<ClCompile Include="unpack.cpp" />
<ClCompile Include="volume.cpp" />
@@ -209,6 +210,7 @@
<ClInclude Include="system.hpp" />
<ClInclude Include="threadpool.hpp" />
<ClInclude Include="timefn.hpp" />
+ <ClInclude Include="ui.hpp" />
<ClInclude Include="ulinks.hpp" />
<ClInclude Include="unicode.hpp" />
<ClInclude Include="unpack.hpp" />
diff --git a/src/thirdparty/unrar/unrar.vcxproj.filters b/src/thirdparty/unrar/unrar.vcxproj.filters
index c3e2710d8..fa5898820 100644
--- a/src/thirdparty/unrar/unrar.vcxproj.filters
+++ b/src/thirdparty/unrar/unrar.vcxproj.filters
@@ -155,6 +155,9 @@
<ClCompile Include="volume.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="ui.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="archive.hpp">
@@ -349,5 +352,8 @@
<ClInclude Include="volume.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="ui.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/src/thirdparty/unrar/uowners.cpp b/src/thirdparty/unrar/uowners.cpp
index 979b60b44..9f4630858 100644
--- a/src/thirdparty/unrar/uowners.cpp
+++ b/src/thirdparty/unrar/uowners.cpp
@@ -7,7 +7,7 @@ void ExtractUnixOwner20(Archive &Arc,const wchar *FileName)
if (Arc.BrokenHeader)
{
- Log(Arc.FileName,St(MOwnersBroken),FileName);
+ uiMsg(UIERROR_UOWNERBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}
@@ -16,7 +16,7 @@ void ExtractUnixOwner20(Archive &Arc,const wchar *FileName)
errno=0; // Required by getpwnam specification if we need to check errno.
if ((pw=getpwnam(Arc.UOHead.OwnerName))==NULL)
{
- Log(Arc.FileName,St(MErrGetOwnerID),GetWide(Arc.UOHead.OwnerName));
+ uiMsg(UIERROR_UOWNERGETOWNERID,Arc.FileName,GetWide(Arc.UOHead.OwnerName));
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_WARNING);
return;
@@ -27,7 +27,7 @@ void ExtractUnixOwner20(Archive &Arc,const wchar *FileName)
errno=0; // Required by getgrnam specification if we need to check errno.
if ((gr=getgrnam(Arc.UOHead.GroupName))==NULL)
{
- Log(Arc.FileName,St(MErrGetGroupID),GetWide(Arc.UOHead.GroupName));
+ uiMsg(UIERROR_UOWNERGETGROUPID,Arc.FileName,GetWide(Arc.UOHead.GroupName));
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_CRC);
return;
@@ -40,7 +40,7 @@ void ExtractUnixOwner20(Archive &Arc,const wchar *FileName)
if (chown(NameA,OwnerID,GroupID)!=0)
#endif
{
- Log(Arc.FileName,St(MSetOwnersError),FileName);
+ uiMsg(UIERROR_UOWNERSET,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CREATE);
}
SetFileAttr(FileName,Attr);
@@ -62,7 +62,7 @@ void ExtractUnixOwner30(Archive &Arc,const wchar *FileName)
struct passwd *pw;
if ((pw=getpwnam(OwnerName))==NULL)
{
- Log(Arc.FileName,St(MErrGetOwnerID),GetWide(OwnerName));
+ uiMsg(UIERROR_UOWNERGETOWNERID,Arc.FileName,GetWide(OwnerName));
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -71,7 +71,7 @@ void ExtractUnixOwner30(Archive &Arc,const wchar *FileName)
struct group *gr;
if ((gr=getgrnam(GroupName))==NULL)
{
- Log(Arc.FileName,St(MErrGetGroupID),GetWide(GroupName));
+ uiMsg(UIERROR_UOWNERGETGROUPID,Arc.FileName,GetWide(GroupName));
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -83,7 +83,7 @@ void ExtractUnixOwner30(Archive &Arc,const wchar *FileName)
if (chown(NameA,OwnerID,GroupID)!=0)
#endif
{
- Log(Arc.FileName,St(MSetOwnersError),FileName);
+ uiMsg(UIERROR_UOWNERSET,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CREATE);
}
SetFileAttr(FileName,Attr);
@@ -106,7 +106,7 @@ void SetUnixOwner(Archive &Arc,const wchar *FileName)
{
if (!hd.UnixOwnerNumeric)
{
- Log(Arc.FileName,St(MErrGetOwnerID),GetWide(hd.UnixOwnerName));
+ uiMsg(UIERROR_UOWNERGETOWNERID,Arc.FileName,GetWide(hd.UnixOwnerName));
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -121,7 +121,7 @@ void SetUnixOwner(Archive &Arc,const wchar *FileName)
{
if (!hd.UnixGroupNumeric)
{
- Log(Arc.FileName,St(MErrGetGroupID),GetWide(hd.UnixGroupName));
+ uiMsg(UIERROR_UOWNERGETGROUPID,Arc.FileName,GetWide(hd.UnixGroupName));
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -135,7 +135,7 @@ void SetUnixOwner(Archive &Arc,const wchar *FileName)
if (chown(NameA,hd.UnixOwnerID,hd.UnixGroupID)!=0)
#endif
{
- Log(Arc.FileName,St(MSetOwnersError),FileName);
+ uiMsg(UIERROR_UOWNERSET,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CREATE);
}
}
diff --git a/src/thirdparty/unrar/version.hpp b/src/thirdparty/unrar/version.hpp
index e28ea9827..4dd805fcb 100644
--- a/src/thirdparty/unrar/version.hpp
+++ b/src/thirdparty/unrar/version.hpp
@@ -1,6 +1,6 @@
#define RARVER_MAJOR 5
-#define RARVER_MINOR 1
-#define RARVER_BETA 0
-#define RARVER_DAY 1
-#define RARVER_MONTH 12
-#define RARVER_YEAR 2013
+#define RARVER_MINOR 10
+#define RARVER_BETA 1
+#define RARVER_DAY 17
+#define RARVER_MONTH 3
+#define RARVER_YEAR 2014
diff --git a/src/thirdparty/unrar/volume.cpp b/src/thirdparty/unrar/volume.cpp
index 6fcab7624..566c6f94c 100644
--- a/src/thirdparty/unrar/volume.cpp
+++ b/src/thirdparty/unrar/volume.cpp
@@ -22,9 +22,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
hd->UnpVer>=20 && hd->FileHash.CRC32!=0xffffffff;
if (PackedHashPresent &&
!DataIO->PackedDataHash.Cmp(&hd->FileHash,hd->UseHashKey ? hd->HashKey:NULL))
- {
- Log(Arc.FileName,St(MDataBadCRC),hd->FileName,Arc.FileName);
- }
+ uiMsg(UIERROR_CHECKSUMPACKED, Arc.FileName, hd->FileName);
}
int64 PosBeforeClose=Arc.Tell();
@@ -48,12 +46,14 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
// In -vp mode we force the pause before next volume even if it is present
// and even if we are on the hard disk. It is important when user does not
// want to process partially downloaded volumes preliminary.
- if (Cmd->VolumePause && !AskNextVol(NextName))
+ if (Cmd->VolumePause && !uiAskNextVolume(NextName,ASIZE(NextName)))
FailedOpen=true;
#endif
+ uint OpenMode = Cmd->OpenShared ? FMF_OPENSHARED : 0;
+
if (!FailedOpen)
- while (!Arc.Open(NextName,0))
+ while (!Arc.Open(NextName,OpenMode))
{
// We need to open a new volume which size was not calculated
// in total size before, so we cannot calculate the total progress
@@ -70,7 +70,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
wcscpy(AltNextName,Arc.FileName);
NextVolumeName(AltNextName,ASIZE(AltNextName),true);
OldSchemeTested=true;
- if (Arc.Open(AltNextName,0))
+ if (Arc.Open(AltNextName,OpenMode))
{
wcscpy(NextName,AltNextName);
break;
@@ -101,7 +101,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
}
#endif
#ifndef SILENT
- if (Cmd->AllYes || !AskNextVol(NextName))
+ if (Cmd->AllYes || !uiAskNextVolume(NextName,ASIZE(NextName)))
#endif
{
FailedOpen=true;
@@ -113,10 +113,8 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
if (FailedOpen)
{
-#ifndef SILENT
- Log(Arc.FileName,St(MAbsNextVol),NextName);
-#endif
- Arc.Open(Arc.FileName,0);
+ uiMsg(UIERROR_MISSINGVOL,NextName);
+ Arc.Open(Arc.FileName,OpenMode);
Arc.Seek(PosBeforeClose,SEEK_SET);
return false;
}
@@ -176,17 +174,6 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
-#ifndef SILENT
-bool AskNextVol(wchar *ArcName)
-{
- eprintf(St(MAskNextVol),ArcName);
- if (Ask(St(MContinueQuit))==2)
- return false;
- return true;
-}
-#endif
-
-
#ifdef RARDLL
#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64)
// Disable the run time stack check for unrar.dll, so we can manipulate
diff --git a/src/thirdparty/unrar/volume.hpp b/src/thirdparty/unrar/volume.hpp
index 4d9a2ee98..2d6a6d5c1 100644
--- a/src/thirdparty/unrar/volume.hpp
+++ b/src/thirdparty/unrar/volume.hpp
@@ -6,6 +6,5 @@ void SplitArchive(Archive &Arc,FileHeader *fh,int64 *HeaderPos,
bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,
wchar Command);
void SetVolWrite(Archive &Dest,int64 VolSize);
-bool AskNextVol(wchar *ArcName);
#endif
diff --git a/src/thirdparty/unrar/win32acl.cpp b/src/thirdparty/unrar/win32acl.cpp
index 28215c9ed..315d4db57 100644
--- a/src/thirdparty/unrar/win32acl.cpp
+++ b/src/thirdparty/unrar/win32acl.cpp
@@ -11,14 +11,14 @@ void ExtractACL20(Archive &Arc,const wchar *FileName)
if (Arc.BrokenHeader)
{
- Log(Arc.FileName,St(MACLBroken),FileName);
+ uiMsg(UIERROR_ACLBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}
if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>VER_PACK)
{
- Log(Arc.FileName,St(MACLUnknown),FileName);
+ uiMsg(UIERROR_ACLUNKNOWN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -38,7 +38,7 @@ void ExtractACL20(Archive &Arc,const wchar *FileName)
if (Arc.EAHead.EACRC!=DataIO.UnpHash.GetCRC32())
{
- Log(Arc.FileName,St(MACLBroken),FileName);
+ uiMsg(UIERROR_ACLBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}
@@ -53,7 +53,7 @@ void ExtractACL20(Archive &Arc,const wchar *FileName)
if (!SetCode)
{
- Log(Arc.FileName,St(MACLSetError),FileName);
+ uiMsg(UIERROR_ACLSET,Arc.FileName,FileName);
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_WARNING);
}
@@ -85,7 +85,7 @@ void ExtractACL(Archive &Arc,const wchar *FileName)
if (!SetCode)
{
- Log(Arc.FileName,St(MACLSetError),FileName);
+ uiMsg(UIERROR_ACLSET,Arc.FileName,FileName);
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_WARNING);
}
diff --git a/src/thirdparty/unrar/win32lnk.cpp b/src/thirdparty/unrar/win32lnk.cpp
index 989e060a7..f911be98e 100644
--- a/src/thirdparty/unrar/win32lnk.cpp
+++ b/src/thirdparty/unrar/win32lnk.cpp
@@ -27,79 +27,6 @@ typedef struct _REPARSE_DATA_BUFFER {
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-void GetReparsePoint(const wchar *Name,FileHeader *hd)
-{
- static bool PrivSet=false;
- if (!PrivSet)
- {
- SetPrivilege(SE_BACKUP_NAME);
- PrivSet=true;
- }
-
- WIN32_FIND_DATA FindData;
- HANDLE hFind=FindFirstFile(Name,&FindData);
- if (hFind==INVALID_HANDLE_VALUE)
- return;
- FindClose(hFind);
-
- if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)==0 ||
- FindData.dwReserved0!=IO_REPARSE_TAG_MOUNT_POINT &&
- FindData.dwReserved0!=IO_REPARSE_TAG_SYMLINK)
- return;
-
- HANDLE hFile=CreateFile(
- Name,FILE_READ_EA,FILE_SHARE_READ,NULL,OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT,NULL);
- if (hFile==INVALID_HANDLE_VALUE)
- {
- ErrHandler.OpenErrorMsg(NULL,Name);
- ErrHandler.SetErrorCode(RARX_OPEN);
- return;
- }
-
- const DWORD BufSize=MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
- Array<byte> Buf(BufSize);
- REPARSE_DATA_BUFFER *rdb=(REPARSE_DATA_BUFFER *)&Buf[0];
-
- DWORD BytesReturned;
- BOOL DevResult=DeviceIoControl(hFile,FSCTL_GET_REPARSE_POINT,NULL,0,rdb,BufSize,&BytesReturned,NULL);
- CloseHandle(hFile);
- if (!DevResult)
- {
- ErrHandler.ReadErrorMsg(Name);
- return;
- }
-
- wchar TargetName[NM];
- if (rdb->ReparseTag==IO_REPARSE_TAG_MOUNT_POINT)
- {
- uint SubstOffset=rdb->MountPointReparseBuffer.SubstituteNameOffset/sizeof(WCHAR);
- uint SubstLength=rdb->MountPointReparseBuffer.SubstituteNameLength/sizeof(WCHAR);
- wchar *SubstName=rdb->MountPointReparseBuffer.PathBuffer+SubstOffset;
-
- if (SubstLength>=ASIZE(TargetName))
- return;
- wcsncpy(TargetName,SubstName,SubstLength);
- TargetName[SubstLength]=0;
- hd->RedirType=FSREDIR_JUNCTION;
- }
- if (rdb->ReparseTag==IO_REPARSE_TAG_SYMLINK)
- {
- uint SubstOffset=rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset/sizeof(WCHAR);
- uint SubstLength=rdb->SymbolicLinkReparseBuffer.SubstituteNameLength/sizeof(WCHAR);
- wchar *SubstName=rdb->SymbolicLinkReparseBuffer.PathBuffer+SubstOffset;
-
- if (SubstLength>=ASIZE(TargetName))
- return;
- wcsncpy(TargetName,SubstName,SubstLength);
- TargetName[SubstLength]=0;
- hd->RedirType=FSREDIR_WINSYMLINK;
- }
- if (hd->RedirType==FSREDIR_NONE)
- return;
- wcsncpyz(hd->RedirName,TargetName,ASIZE(hd->RedirName));
- hd->DirTarget=(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)!=0;
-}
bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd)
@@ -210,9 +137,9 @@ bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd)
rdb->ReparseDataLength,NULL,0,&Returned,NULL))
{
CloseHandle(hFile);
- Log(NULL,St(MErrCreateLnkS),Name);
+ uiMsg(UIERROR_SLINKCREATE,UINULL,Name);
if (GetLastError()==ERROR_PRIVILEGE_NOT_HELD)
- Log(NULL,St(MNeedAdmin));
+ uiMsg(UIERROR_NEEDADMIN);
ErrHandler.SysErrMsg();
ErrHandler.SetErrorCode(RARX_CREATE);
diff --git a/src/thirdparty/unrar/win32stm.cpp b/src/thirdparty/unrar/win32stm.cpp
index ecbef7a07..edcd7b5fa 100644
--- a/src/thirdparty/unrar/win32stm.cpp
+++ b/src/thirdparty/unrar/win32stm.cpp
@@ -5,18 +5,14 @@ void ExtractStreams20(Archive &Arc,const wchar *FileName)
{
if (Arc.BrokenHeader)
{
-#ifndef SILENT
- Log(Arc.FileName,St(MStreamBroken),FileName);
-#endif
+ uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}
if (Arc.StreamHead.Method<0x31 || Arc.StreamHead.Method>0x35 || Arc.StreamHead.UnpVer>VER_PACK)
{
-#ifndef SILENT
- Log(Arc.FileName,St(MStreamUnknown),FileName);
-#endif
+ uiMsg(UIERROR_STREAMUNKNOWN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_WARNING);
return;
}
@@ -32,9 +28,7 @@ void ExtractStreams20(Archive &Arc,const wchar *FileName)
if (wcslen(StreamName)+strlen(Arc.StreamHead.StreamName)>=ASIZE(StreamName) ||
Arc.StreamHead.StreamName[0]!=':')
{
-#ifndef SILENT
- Log(Arc.FileName,St(MStreamBroken),FileName);
-#endif
+ uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}
@@ -67,9 +61,7 @@ void ExtractStreams20(Archive &Arc,const wchar *FileName)
if (Arc.StreamHead.StreamCRC!=DataIO.UnpHash.GetCRC32())
{
-#ifndef SILENT
- Log(Arc.FileName,St(MStreamBroken),StreamName);
-#endif
+ uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,StreamName);
ErrHandler.SetErrorCode(RARX_CRC);
}
else
@@ -104,9 +96,7 @@ void ExtractStreams(Archive &Arc,const wchar *FileName)
GetStreamNameNTFS(Arc,StreamName,ASIZE(StreamName));
if (*StreamName!=':')
{
-#if !defined(SILENT) && !defined(SFX_MODULE)
- Log(Arc.FileName,St(MStreamBroken),FileName);
-#endif
+ uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName);
ErrHandler.SetErrorCode(RARX_CRC);
return;
}