Skip to content

Commit 1dc896b

Browse files
committed
Merge branch 'unrar', with unrar 6.0.2
2 parents 91ed5b0 + 36345d0 commit 1dc896b

20 files changed

+309
-68
lines changed

unrar/cmddata.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
5656
// In Windows we may prefer to implement our own command line parser
5757
// to avoid replacing \" by " in standard parser. Such replacing corrupts
5858
// destination paths like "dest path\" in extraction commands.
59-
// Also our own parser is Unicode compatible.
6059
const wchar *CmdLine=GetCommandLine();
6160

6261
wchar *Par;
@@ -288,7 +287,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
288287
AppendArcNameToPath=APPENDARCNAME_DESTPATH;
289288
else
290289
if (Switch[2]=='1')
291-
AppendArcNameToPath=APPENDARCNAME_OWNDIR;
290+
AppendArcNameToPath=APPENDARCNAME_OWNSUBDIR;
291+
else
292+
if (Switch[2]=='2')
293+
AppendArcNameToPath=APPENDARCNAME_OWNDIR;
292294
break;
293295
#ifndef SFX_MODULE
294296
case 'G':
@@ -436,9 +438,9 @@ void CommandData::ProcessSwitch(const wchar *Switch)
436438
wcsncpyz(EmailTo,Switch[4]!=0 ? Switch+4:L"@",ASIZE(EmailTo));
437439
break;
438440
}
439-
if (wcsicomp(Switch+1,L"M")==0)
441+
if (wcsicomp(Switch+1,L"M")==0) // For compatibility with pre-WinRAR 6.0 -im syntax. Replaced with -idv.
440442
{
441-
MoreInfo=true;
443+
VerboseOutput=true;
442444
break;
443445
}
444446
if (wcsicomp(Switch+1,L"NUL")==0)
@@ -465,6 +467,12 @@ void CommandData::ProcessSwitch(const wchar *Switch)
465467
case 'P':
466468
DisablePercentage=true;
467469
break;
470+
case 'N':
471+
DisableNames=true;
472+
break;
473+
case 'V':
474+
VerboseOutput=true;
475+
break;
468476
}
469477
break;
470478
}
@@ -539,7 +547,6 @@ void CommandData::ProcessSwitch(const wchar *Switch)
539547
case 'D': Type=FILTER_DELTA; break;
540548
case 'A': Type=FILTER_AUDIO; break;
541549
case 'C': Type=FILTER_RGB; break;
542-
case 'I': Type=FILTER_ITANIUM; break;
543550
case 'R': Type=FILTER_ARM; break;
544551
}
545552
if (*Str=='+' || *Str=='-')

unrar/cmddata.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ enum IS_PROCESS_FILE_FLAGS {IPFF_EXCLUDE_PARENT=1};
1111
class CommandData:public RAROptions
1212
{
1313
private:
14-
void ProcessSwitchesString(const wchar *Str);
1514
void ProcessSwitch(const wchar *Switch);
1615
void BadSwitch(const wchar *Switch);
1716
uint GetExclAttr(const wchar *Str,bool &Dir);
@@ -34,6 +33,7 @@ class CommandData:public RAROptions
3433
void ParseEnvVar();
3534
void ReadConfig();
3635
void PreprocessArg(const wchar *Arg);
36+
void ProcessSwitchesString(const wchar *Str);
3737
void OutTitle();
3838
void OutHelp(RAR_EXIT ExitCode);
3939
bool IsSwitch(int Ch);

unrar/consio.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void GetPasswordText(wchar *Str,uint MaxLength)
164164
SetConsoleMode(hConIn,ConInMode);
165165
SetConsoleMode(hConOut,ConOutMode);
166166
#else
167-
char StrA[MAXPASSWORD];
167+
char StrA[MAXPASSWORD*4]; // "*4" for multibyte UTF-8 characters.
168168
#if defined(_EMX) || defined (__VMS)
169169
fgets(StrA,ASIZE(StrA)-1,stdin);
170170
#elif defined(__sun)
@@ -248,6 +248,12 @@ bool getwstr(wchar *str,size_t n)
248248
ErrHandler.Exit(RARX_USERBREAK);
249249
}
250250
StrA[ReadSize]=0;
251+
252+
// We expect ANSI encoding here, but "echo text|rar ..." to pipe to RAR,
253+
// such as send passwords, we get OEM encoding by default, unless we
254+
// use "chcp" in console. But we avoid OEM to ANSI conversion,
255+
// because we also want to handle ANSI files redirection correctly,
256+
// like "rar ... < ansifile.txt".
251257
CharToWide(&StrA[0],str,n);
252258
cleandata(&StrA[0],StrA.Size()); // We can use this function to enter passwords.
253259
}
@@ -305,7 +311,7 @@ int Ask(const wchar *AskStr)
305311

306312
for (int I=0;I<NumItems;I++)
307313
{
308-
eprintf(I==0 ? (NumItems>4 ? L"\n":L" "):L", ");
314+
eprintf(I==0 ? (NumItems>3 ? L"\n":L" "):L", ");
309315
int KeyPos=ItemKeyPos[I];
310316
for (int J=0;J<KeyPos;J++)
311317
eprintf(L"%c",Item[I][J]);

unrar/dll.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static int RarErrorToDll(RAR_EXIT ErrCode)
552552
switch(ErrCode)
553553
{
554554
case RARX_FATAL:
555+
case RARX_READ:
555556
return ERAR_EREAD;
556557
case RARX_CRC:
557558
return ERAR_BAD_DATA;

unrar/dll.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <commctrl.h>
33

44
VS_VERSION_INFO VERSIONINFO
5-
FILEVERSION 5, 91, 100, 3470
6-
PRODUCTVERSION 5, 91, 100, 3470
5+
FILEVERSION 6, 0, 2, 3610
6+
PRODUCTVERSION 6, 0, 2, 3610
77
FILEOS VOS__WINDOWS32
88
FILETYPE VFT_APP
99
{
@@ -14,8 +14,8 @@ FILETYPE VFT_APP
1414
VALUE "CompanyName", "Alexander Roshal\0"
1515
VALUE "ProductName", "RAR decompression library\0"
1616
VALUE "FileDescription", "RAR decompression library\0"
17-
VALUE "FileVersion", "5.91.0\0"
18-
VALUE "ProductVersion", "5.91.0\0"
17+
VALUE "FileVersion", "6.0.2\0"
18+
VALUE "ProductVersion", "6.0.2\0"
1919
VALUE "LegalCopyright", "Copyright � Alexander Roshal 1993-2020\0"
2020
VALUE "OriginalFilename", "Unrar.dll\0"
2121
}

unrar/errhnd.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void ErrorHandler::Clean()
1515
UserBreak=false;
1616
MainExit=false;
1717
DisableShutdown=false;
18+
ReadErrIgnoreAll=false;
1819
}
1920

2021

@@ -56,24 +57,34 @@ void ErrorHandler::ReadError(const wchar *FileName)
5657
ReadErrorMsg(FileName);
5758
#endif
5859
#if !defined(SILENT) || defined(RARDLL)
59-
Exit(RARX_FATAL);
60+
Exit(RARX_READ);
6061
#endif
6162
}
6263

6364

64-
bool ErrorHandler::AskRepeatRead(const wchar *FileName)
65+
void ErrorHandler::AskRepeatRead(const wchar *FileName,bool &Ignore,bool &Retry,bool &Quit)
6566
{
67+
SetErrorCode(RARX_READ);
6668
#if !defined(SILENT) && !defined(SFX_MODULE)
6769
if (!Silent)
6870
{
71+
uiMsg(UIERROR_FILEREAD,UINULL,FileName);
6972
SysErrMsg();
70-
bool Repeat=uiAskRepeatRead(FileName);
71-
if (!Repeat) // Disable shutdown if user pressed Cancel in error dialog.
72-
DisableShutdown=true;
73-
return Repeat;
73+
if (ReadErrIgnoreAll)
74+
Ignore=true;
75+
else
76+
{
77+
bool All=false;
78+
uiAskRepeatRead(FileName,Ignore,All,Retry,Quit);
79+
if (All)
80+
ReadErrIgnoreAll=Ignore=true;
81+
if (Quit) // Disable shutdown if user select Quit in read error prompt.
82+
DisableShutdown=true;
83+
}
84+
return;
7485
}
7586
#endif
76-
return false;
87+
Ignore=true; // Saving the file part for -y or -inul or "Ignore all" choice.
7788
}
7889

7990

@@ -189,7 +200,7 @@ void ErrorHandler::ReadErrorMsg(const wchar *ArcName,const wchar *FileName)
189200
{
190201
uiMsg(UIERROR_FILEREAD,ArcName,FileName);
191202
SysErrMsg();
192-
SetErrorCode(RARX_FATAL);
203+
SetErrorCode(RARX_READ);
193204
}
194205

195206

unrar/errhnd.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ enum RAR_EXIT // RAR exit code.
1515
RARX_CREATE = 9,
1616
RARX_NOFILES = 10,
1717
RARX_BADPWD = 11,
18+
RARX_READ = 12,
1819
RARX_USERBREAK = 255
1920
};
2021

22+
2123
class ErrorHandler
2224
{
2325
private:
@@ -26,14 +28,15 @@ class ErrorHandler
2628
bool EnableBreak;
2729
bool Silent;
2830
bool DisableShutdown; // Shutdown is not suitable after last error.
31+
bool ReadErrIgnoreAll;
2932
public:
3033
ErrorHandler();
3134
void Clean();
3235
void MemoryError();
3336
void OpenError(const wchar *FileName);
3437
void CloseError(const wchar *FileName);
3538
void ReadError(const wchar *FileName);
36-
bool AskRepeatRead(const wchar *FileName);
39+
void AskRepeatRead(const wchar *FileName,bool &Ignore,bool &Retry,bool &Quit);
3740
void WriteError(const wchar *ArcName,const wchar *FileName);
3841
void WriteErrorFAT(const wchar *FileName);
3942
bool AskRepeatWrite(const wchar *FileName,bool DiskFull);

0 commit comments

Comments
 (0)