MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / Restore

Method Restore

Libraries/unrar/recvol3.cpp:102–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
103{
104 wchar ArcName[NM];
105 wcsncpyz(ArcName,Name,ASIZE(ArcName));
106 wchar *Ext=GetExt(ArcName);
107 bool NewStyle=false; // New style .rev volumes are supported since RAR 3.10.
108 bool RevName=Ext!=NULL && wcsicomp(Ext,L".rev")==0;
109 if (RevName)
110 {
111 NewStyle=IsNewStyleRev(ArcName);
112 while (Ext>ArcName+1 && (IsDigit(*(Ext-1)) || *(Ext-1)=='_'))
113 Ext--;
114 wcsncpyz(Ext,L"*.*",ASIZE(ArcName)-(Ext-ArcName));
115
116 FindFile Find;
117 Find.SetMask(ArcName);
118 FindData fd;
119 while (Find.Next(&fd))
120 {
121 Archive Arc(Cmd);
122 if (Arc.WOpen(fd.Name) && Arc.IsArchive(true))
123 {
124 wcsncpyz(ArcName,fd.Name,ASIZE(ArcName));
125 break;
126 }
127 }
128 }
129
130 Archive Arc(Cmd);
131 if (!Arc.WCheckOpen(ArcName))
132 return false;
133 if (!Arc.Volume)
134 {
135 uiMsg(UIERROR_NOTVOLUME,ArcName);
136 return false;
137 }
138 bool NewNumbering=Arc.NewNumbering;
139 Arc.Close();
140
141 wchar *VolNumStart=VolNameToFirstName(ArcName,ArcName,ASIZE(ArcName),NewNumbering);
142 wchar RecVolMask[NM];
143 wcsncpyz(RecVolMask,ArcName,ASIZE(RecVolMask));
144 size_t BaseNamePartLength=VolNumStart-ArcName;
145 wcsncpyz(RecVolMask+BaseNamePartLength,L"*.rev",ASIZE(RecVolMask)-BaseNamePartLength);
146
147 int64 RecFileSize=0;
148
149 // We cannot display "Calculating CRC..." message here, because we do not
150 // know if we'll find any recovery volumes. We'll display it after finding
151 // the first recovery volume.
152 bool CalcCRCMessageDone=false;
153
154 FindFile Find;
155 Find.SetMask(RecVolMask);
156 FindData RecData;
157 int FileNumber=0,RecVolNumber=0,FoundRecVolumes=0,MissingVolumes=0;
158 wchar PrevName[NM];
159 while (Find.Next(&RecData))

Callers

nothing calls this directly

Calls 15

wcsncpyzFunction · 0.85
GetExtFunction · 0.85
wcsicompFunction · 0.85
IsNewStyleRevFunction · 0.85
IsDigitFunction · 0.85
uiMsgFunction · 0.85
VolNameToFirstNameFunction · 0.85
CalcFileSumFunction · 0.85
atoiwFunction · 0.85
FileExistFunction · 0.85
wcsncatzFunction · 0.85
RenameFileFunction · 0.85

Tested by

no test coverage detected