Skip to content

Commit

Permalink
Add new option to wait for the next volume to appear
Browse files Browse the repository at this point in the history
If the next volume got found, the file size gets checked in the given
interval until it doesn't change anymore.
The default interval is 5 seconds.

command line option:
-vap<interval> Wait for each volume to appear, check interval in seconds

(From:
dfaust/unrar@01b62cc)
  • Loading branch information
itouch5000 committed Sep 28, 2016
1 parent 2faa08e commit 4159010
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 18 deletions.
24 changes: 19 additions & 5 deletions cmddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void CommandData::ParseArg(wchar *Arg)
{
FindData FileData;
bool Found=FindFile::FastFind(Arg,&FileData);
if ((!Found || ListMode==RCLM_ACCEPT_LISTS) &&
if ((!Found || ListMode==RCLM_ACCEPT_LISTS) &&
ListMode!=RCLM_REJECT_LISTS && *Arg=='@' && !IsWildcard(Arg))
{
FileLists=true;
Expand Down Expand Up @@ -866,6 +866,20 @@ void CommandData::ProcessSwitch(const wchar *Switch)
case 'P':
VolumePause=true;
break;
case 'A':
if (toupperw(Switch[2])=='P')
{
VolumeAutoPause=true;
if (IsDigit(Switch[3]))
{
VolumeAutoPauseInterval=atoiw(Switch+3);
}
else
{
VolumeAutoPauseInterval=5;
}
}
break;
case 'E':
if (toupperw(Switch[2])=='R')
VersionControl=atoiw(Switch+3)+1;
Expand Down Expand Up @@ -992,8 +1006,8 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSL,MCHelpSwSM,
MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,
MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,
MCHelpSwY
MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwVAP,MCHelpSwX,MCHelpSwXa,
MCHelpSwXal,MCHelpSwY
#else
#endif
};
Expand Down Expand Up @@ -1077,15 +1091,15 @@ bool CommandData::CheckArgs(StringList *Args,bool Dir,const wchar *CheckName,boo
{
// We process the directory and have the directory exclusion mask.
// So let's convert "mask\" to "mask" and process it normally.

*LastMaskChar=0;
}
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;
}
Expand Down
12 changes: 7 additions & 5 deletions loclang.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
#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 MCHelpSwVAP L"\n vap<interval> Wait for each volume to appear, check interval in seconds"
#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"
Expand All @@ -164,6 +165,7 @@
#define MAskNextDisk L"\nDisk full. Insert next"
#define MCreatVol L"\n\nCreating %sarchive %s\n"
#define MAskNextVol L"\nInsert disk with %s"
#define MWaitNextVol L"\nWaiting for %s to appear\n"
#define MTestVol L"\n\nTesting archive %s\n"
#define MExtrVol L"\n\nExtracting from %s\n"
#define MConverting L"\nConverting %s"
Expand Down Expand Up @@ -353,11 +355,11 @@
#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 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"
Expand Down
8 changes: 5 additions & 3 deletions options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ enum {NAMES_ORIGINALCASE=0,NAMES_UPPERCASE,NAMES_LOWERCASE};

enum MESSAGE_TYPE {MSG_STDOUT=0,MSG_STDERR,MSG_ERRONLY,MSG_NULL};

enum RECURSE_MODE
enum RECURSE_MODE
{
RECURSE_NONE=0, // no recurse switches
RECURSE_DISABLE, // switch -r-
RECURSE_ALWAYS, // switch -r
RECURSE_WILDCARDS, // switch -r0
};

enum OVERWRITE_MODE
enum OVERWRITE_MODE
{
OVERWRITE_DEFAULT=0, // Ask when extracting, silently overwrite when archiving.
OVERWRITE_ALL,
Expand Down Expand Up @@ -100,7 +100,7 @@ class RAROptions
wchar ArcPath[NM];
SecPassword Password;
bool EncryptHeaders;

bool ManualPassword; // Password entered manually during operation, might need to clean for next archive.

wchar LogName[NM];
Expand Down Expand Up @@ -162,6 +162,8 @@ class RAROptions
bool Lock;
bool Test;
bool VolumePause;
bool VolumeAutoPause;
uint VolumeAutoPauseInterval;
FilterMode FilterModes[MAX_FILTER_TYPES];
wchar EmailTo[NM];
uint VersionControl;
Expand Down
32 changes: 27 additions & 5 deletions volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma

if (DataIO!=NULL && SplitHeader)
{
bool PackedHashPresent=Arc.Format==RARFMT50 ||
bool PackedHashPresent=Arc.Format==RARFMT50 ||
hd->UnpVer>=20 && hd->FileHash.CRC32!=0xffffffff;
if (PackedHashPresent &&
if (PackedHashPresent &&
!DataIO->PackedDataHash.Cmp(&hd->FileHash,hd->UseHashKey ? hd->HashKey:NULL))
uiMsg(UIERROR_CHECKSUMPACKED, Arc.FileName, hd->FileName);
}
Expand Down Expand Up @@ -50,14 +50,19 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
FailedOpen=true;
#endif

if (Cmd->VolumeAutoPause)
{
WaitNextVol(NextName,Cmd->VolumeAutoPauseInterval);
}

uint OpenMode = Cmd->OpenShared ? FMF_OPENSHARED : 0;

if (!FailedOpen)
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
// anymore. Let's reset the total size to zero and stop
// anymore. Let's reset the total size to zero and stop
// the total progress.
if (DataIO!=NULL)
DataIO->TotalArcSize=0;
Expand Down Expand Up @@ -110,7 +115,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma

#endif // RARDLL
}

if (FailedOpen)
{
uiMsg(UIERROR_MISSINGVOL,NextName);
Expand Down Expand Up @@ -158,7 +163,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
#ifdef SFX_MODULE
DataIO->UnpArcSize=Arc.FileLength();
#endif

// Reset the size of packed data read from current volume. It is used
// to display the total progress and preceding volumes are already
// compensated with ProcessedArcSize, so we need to reset this variable.
Expand All @@ -170,6 +175,23 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
}


void WaitNextVol(wchar *ArcName,uint Interval)
{
eprintf(St(MWaitNextVol),ArcName);
while (!FileExist(ArcName))
{
sleep(Interval);
}
File *ArcFile=new File();
ArcFile->Open(ArcName,FMF_READ);
int64 ArcFileLastSize=0, ArcFileSize=1;
while (ArcFileSize!=ArcFileLastSize)
{
ArcFileLastSize=ArcFileSize;
sleep(Interval);
ArcFileSize=ArcFile->FileLength();
}
}



Expand Down
1 change: 1 addition & 0 deletions volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ void SplitArchive(Archive &Arc,FileHeader *fh,int64 *HeaderPos,
bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,
wchar Command);
void SetVolWrite(Archive &Dest,int64 VolSize);
void WaitNextVol(wchar *ArcName,uint Interval);

#endif

0 comments on commit 4159010

Please sign in to comment.