1 #include "rar.hpp"
2 
3 #include "recvol3.cpp"
4 #include "recvol5.cpp"
5 
6 
7 
RecVolumesRestore(RAROptions * Cmd,const wchar * Name,bool Silent)8 bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent)
9 {
10   Archive Arc(Cmd);
11   if (!Arc.Open(Name))
12   {
13     if (!Silent)
14       ErrHandler.OpenErrorMsg(Name);
15     return false;
16   }
17 
18   RARFORMAT Fmt=RARFMT15;
19   if (Arc.IsArchive(true))
20     Fmt=Arc.Format;
21   else
22   {
23     byte Sign[REV5_SIGN_SIZE];
24     Arc.Seek(0,SEEK_SET);
25     if (Arc.Read(Sign,REV5_SIGN_SIZE)==REV5_SIGN_SIZE && memcmp(Sign,REV5_SIGN,REV5_SIGN_SIZE)==0)
26       Fmt=RARFMT50;
27   }
28   Arc.Close();
29 
30   // We define RecVol as local variable for proper stack unwinding when
31   // handling exceptions. So it can close and delete files on Cancel.
32   if (Fmt==RARFMT15)
33   {
34     RecVolumes3 RecVol;
35     return RecVol.Restore(Cmd,Name,Silent);
36   }
37   else
38   {
39     RecVolumes5 RecVol;
40     return RecVol.Restore(Cmd,Name,Silent);
41   }
42 }
43