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:
Diffstat (limited to 'src/thirdparty/unrar/cmddata.cpp')
-rw-r--r--src/thirdparty/unrar/cmddata.cpp84
1 files changed, 65 insertions, 19 deletions
diff --git a/src/thirdparty/unrar/cmddata.cpp b/src/thirdparty/unrar/cmddata.cpp
index 3f84cc373..8502210f6 100644
--- a/src/thirdparty/unrar/cmddata.cpp
+++ b/src/thirdparty/unrar/cmddata.cpp
@@ -52,6 +52,7 @@ void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
// In Windows we may prefer to implement our own command line parser
// to avoid replacing \" by " in standard parser. Such replacing corrupts
// destination paths like "dest path\" in extraction commands.
+ // Also our own parser is Unicode compatible.
const wchar *CmdLine=GetCommandLine();
wchar *Par;
@@ -466,6 +467,11 @@ void CommandData::ProcessSwitch(const wchar *Switch)
Shutdown=true;
break;
}
+ if (wcsicomp(Switch+1,L"VER")==0)
+ {
+ PrintVersion=true;
+ break;
+ }
break;
case 'K':
switch(toupperw(Switch[1]))
@@ -620,6 +626,12 @@ void CommandData::ProcessSwitch(const wchar *Switch)
AbsoluteLinks=true;
break;
#endif
+#ifdef _WIN_ALL
+ case 'N':
+ if (toupperw(Switch[2])=='I')
+ AllowIncompatNames=true;
+ break;
+#endif
case 'R':
Overwrite=OVERWRITE_AUTORENAME;
break;
@@ -766,6 +778,9 @@ void CommandData::ProcessSwitch(const wchar *Switch)
case 'L':
FilelistCharset=rch;
break;
+ case 'R':
+ RedirectCharset=rch;
+ break;
default:
BadSwitch(Switch);
AlreadyBad=true;
@@ -916,12 +931,26 @@ void CommandData::OutTitle()
if (TitleShown)
return;
TitleShown=true;
- wchar Version[50];
- int Beta=RARVER_BETA;
- if (Beta!=0)
+
+ wchar Version[80];
+ if (RARVER_BETA!=0)
swprintf(Version,ASIZE(Version),L"%d.%02d %ls %d",RARVER_MAJOR,RARVER_MINOR,St(MBeta),RARVER_BETA);
else
swprintf(Version,ASIZE(Version),L"%d.%02d",RARVER_MAJOR,RARVER_MINOR);
+#if defined(_WIN_32) || defined(_WIN_64)
+ wcsncatz(Version,L" ",ASIZE(Version));
+#endif
+#ifdef _WIN_32
+ wcsncatz(Version,St(Mx86),ASIZE(Version));
+#endif
+#ifdef _WIN_64
+ wcsncatz(Version,St(Mx64),ASIZE(Version));
+#endif
+ if (PrintVersion)
+ {
+ mprintf(L"%s",Version);
+ exit(0);
+ }
#ifdef UNRAR
mprintf(St(MUCopyright),Version,RARVER_YEAR);
#else
@@ -977,7 +1006,7 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
#ifndef _WIN_ALL
static MSGID Win32Only[]={
MCHelpSwIEML,MCHelpSwVD,MCHelpSwAO,MCHelpSwOS,MCHelpSwIOFF,
- MCHelpSwEP2,MCHelpSwOC,MCHelpSwDR,MCHelpSwRI
+ MCHelpSwEP2,MCHelpSwOC,MCHelpSwONI,MCHelpSwDR,MCHelpSwRI
};
bool Found=false;
for (int J=0;J<sizeof(Win32Only)/sizeof(Win32Only[0]);J++)
@@ -1019,24 +1048,24 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
// the include list created with -n switch.
bool CommandData::ExclCheck(const wchar *CheckName,bool Dir,bool CheckFullPath,bool CheckInclList)
{
- if (ExclCheckArgs(&ExclArgs,Dir,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
+ if (CheckArgs(&ExclArgs,Dir,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
return true;
if (!CheckInclList || InclArgs.ItemsCount()==0)
return false;
- if (ExclCheckArgs(&InclArgs,Dir,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
+ if (CheckArgs(&InclArgs,Dir,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
return false;
return true;
}
-bool CommandData::ExclCheckArgs(StringList *Args,bool Dir,const wchar *CheckName,bool CheckFullPath,int MatchMode)
+bool CommandData::CheckArgs(StringList *Args,bool Dir,const wchar *CheckName,bool CheckFullPath,int MatchMode)
{
wchar *Name=ConvertPath(CheckName,NULL);
wchar FullName[NM];
- wchar CurMask[NM+1]; // We reserve the space to append "*" to mask.
+ wchar CurMask[NM];
*FullName=0;
Args->Rewind();
- while (Args->GetString(CurMask,ASIZE(CurMask)-1))
+ while (Args->GetString(CurMask,ASIZE(CurMask)))
{
wchar *LastMaskChar=PointToLastChar(CurMask);
bool DirMask=IsPathDiv(*LastMaskChar); // Mask for directories only.
@@ -1053,23 +1082,24 @@ bool CommandData::ExclCheckArgs(StringList *Args,bool Dir,const wchar *CheckName
}
else
{
+ // REMOVED, we want -npath\* to match empty folders too.
// If mask has wildcards in name part and does not have the trailing
// '\' character, we cannot use it for directories.
- if (IsWildcard(PointToName(CurMask)))
- continue;
+ // if (IsWildcard(PointToName(CurMask)))
+ // continue;
}
}
else
{
// If we process a file inside of directory excluded by "dirmask\".
// we want to exclude such file too. So we convert "dirmask\" to
- // "dirmask\*". It is important for operations other than archiving.
- // When archiving, directory matched by "dirmask\" is excluded
- // from further scanning.
+ // "dirmask\*". It is important for operations other than archiving
+ // with -x. When archiving with -x, directory matched by "dirmask\"
+ // is excluded from further scanning.
if (DirMask)
- wcscat(CurMask,L"*");
+ wcsncatz(CurMask,L"*",ASIZE(CurMask));
}
#ifndef SFX_MODULE
@@ -1090,7 +1120,12 @@ bool CommandData::ExclCheckArgs(StringList *Args,bool Dir,const wchar *CheckName
#endif
{
wchar NewName[NM+2],*CurName=Name;
- if (CurMask[0]=='*' && IsPathDiv(CurMask[1]))
+
+ // Important to convert before "*\" check below, so masks like
+ // d:*\something are processed properly.
+ wchar *CmpMask=ConvertPath(CurMask,NULL);
+
+ if (CmpMask[0]=='*' && IsPathDiv(CmpMask[1]))
{
// We want "*\name" to match 'name' not only in subdirectories,
// but also in the current directory. We convert the name
@@ -1102,7 +1137,7 @@ bool CommandData::ExclCheckArgs(StringList *Args,bool Dir,const wchar *CheckName
CurName=NewName;
}
- if (CmpName(ConvertPath(CurMask,NULL),CurName,MatchMode))
+ if (CmpName(CmpMask,CurName,MatchMode))
return true;
}
}
@@ -1201,13 +1236,24 @@ void CommandData::ProcessCommand()
if (Command[0]!=0 && Command[1]!=0 && wcschr(SingleCharCommands,Command[0])!=NULL || *ArcName==0)
OutHelp(*Command==0 ? RARX_SUCCESS:RARX_USERERROR); // Return 'success' for 'rar' without parameters.
+ const wchar *ArcExt=GetExt(ArcName);
#ifdef _UNIX
- if (GetExt(ArcName)==NULL && (!FileExist(ArcName) || IsDir(GetFileAttr(ArcName))))
+ if (ArcExt==NULL && (!FileExist(ArcName) || IsDir(GetFileAttr(ArcName))))
wcsncatz(ArcName,L".rar",ASIZE(ArcName));
#else
- if (GetExt(ArcName)==NULL)
+ if (ArcExt==NULL)
wcsncatz(ArcName,L".rar",ASIZE(ArcName));
#endif
+ // Treat arcname.part1 as arcname.part1.rar.
+ if (ArcExt!=NULL && wcsnicomp(ArcExt,L".part",5)==0 && IsDigit(ArcExt[5]) &&
+ !FileExist(ArcName))
+ {
+ wchar Name[NM];
+ wcsncpyz(Name,ArcName,ASIZE(Name));
+ wcsncatz(Name,L".rar",ASIZE(Name));
+ if (FileExist(Name))
+ wcsncpyz(ArcName,Name,ASIZE(ArcName));
+ }
if (wcschr(L"AFUMD",*Command)==NULL)
{