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
  • Loading branch information
dfaust committed Feb 8, 2014
1 parent e260188 commit 01b62cc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,16 @@ 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 @@ -954,7 +964,7 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
MCHelpSwO,MCHelpSwOC,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,
MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,
MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY
MCHelpSwVER,MCHelpSwVP,MCHelpSwVAP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY
#else
#endif
};
Expand Down
2 changes: 2 additions & 0 deletions loclang.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
#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 MCHelpSwVAP "\n vap<interval> Wait for each volume to appear, check interval in seconds"
#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"
Expand All @@ -161,6 +162,7 @@
#define MAskNextDisk "\nDisk full. Insert next"
#define MCreatVol "\n\nCreating %sarchive %s\n"
#define MAskNextVol "\nInsert disk with %s"
#define MWaitNextVol "\nWaiting for %s to appear"
#define MTestVol "\n\nTesting archive %s\n"
#define MExtrVol "\n\nExtracting from %s\n"
#define MConverting "\nConverting %s"
Expand Down
2 changes: 2 additions & 0 deletions options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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
24 changes: 24 additions & 0 deletions volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma
FailedOpen=true;
#endif

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

if (!FailedOpen)
while (!Arc.Open(NextName,0))
{
Expand Down Expand Up @@ -187,6 +192,25 @@ bool AskNextVol(wchar *ArcName)
#endif


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();
}
}


#ifdef RARDLL
#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64)
// Disable the run time stack check for unrar.dll, so we can manipulate
Expand Down
1 change: 1 addition & 0 deletions volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,
wchar Command);
void SetVolWrite(Archive &Dest,int64 VolSize);
bool AskNextVol(wchar *ArcName);
void WaitNextVol(wchar *ArcName,uint Interval);

#endif

0 comments on commit 01b62cc

Please sign in to comment.