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

Method Restore

Libraries/unrar/recvol5.cpp:140–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139
140bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent)
141{
142 wchar ArcName[NM];
143 wcsncpyz(ArcName,Name,ASIZE(ArcName));
144
145 wchar *Num=GetVolNumPart(ArcName);
146 while (Num>ArcName && IsDigit(*(Num-1)))
147 Num--;
148 if (Num==ArcName)
149 return false; // Numeric part is missing or entire volume name is numeric, not possible for RAR or REV volume.
150 wcsncpyz(Num,L"*.*",ASIZE(ArcName)-(Num-ArcName));
151
152 wchar FirstVolName[NM];
153 *FirstVolName=0;
154
155 int64 RecFileSize=0;
156
157 FindFile VolFind;
158 VolFind.SetMask(ArcName);
159 FindData fd;
160 uint FoundRecVolumes=0;
161 while (VolFind.Next(&fd))
162 {
163 Wait();
164
165 Archive *Vol=new Archive(Cmd);
166 int ItemPos=-1;
167 if (Vol->WOpen(fd.Name))
168 {
169 if (CmpExt(fd.Name,L"rev"))
170 {
171 uint RecNum=ReadHeader(Vol,FoundRecVolumes==0);
172 if (RecNum!=0)
173 {
174 if (FoundRecVolumes==0)
175 RecFileSize=Vol->FileLength();
176
177 ItemPos=RecNum;
178 FoundRecVolumes++;
179 }
180 }
181 else
182 if (Vol->IsArchive(true) && (Vol->SFXSize>0 || CmpExt(fd.Name,L"rar")))
183 {
184 if (!Vol->Volume && !Vol->BrokenHeader)
185 {
186 uiMsg(UIERROR_NOTVOLUME,ArcName);
187 return false;
188 }
189 // We work with archive as with raw data file, so we do not want
190 // to spend time to QOpen I/O redirection.
191 Vol->QOpenUnload();
192
193 Vol->Seek(0,SEEK_SET);
194
195 // RAR volume found. Get its number, store the handle in appropriate
196 // array slot, clean slots in between if we had to grow the array.
197 wchar *Num=GetVolNumPart(fd.Name);

Callers 1

RecVolumesRestoreFunction · 0.45

Calls 15

wcsncpyzFunction · 0.85
GetVolNumPartFunction · 0.85
IsDigitFunction · 0.85
WaitFunction · 0.85
CmpExtFunction · 0.85
uiMsgFunction · 0.85
VolNameToFirstNameFunction · 0.85
CalcFileSumFunction · 0.85
wcsncatzFunction · 0.85
RenameFileFunction · 0.85
FileCreateFunction · 0.85
NextVolumeNameFunction · 0.85

Tested by

no test coverage detected