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

Function RARReadHeaderEx

Libraries/unrar/dll.cpp:209–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *D)
210{
211 DataSet *Data=(DataSet *)hArcData;
212 try
213 {
214 if ((Data->HeaderSize=(int)Data->Arc.SearchBlock(HEAD_FILE))<=0)
215 {
216 if (Data->Arc.Volume && Data->Arc.GetHeaderType()==HEAD_ENDARC &&
217 Data->Arc.EndArcHead.NextVolume)
218 if (MergeArchive(Data->Arc,NULL,false,'L'))
219 {
220 Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
221 return RARReadHeaderEx(hArcData,D);
222 }
223 else
224 return ERAR_EOPEN;
225
226 if (Data->Arc.BrokenHeader)
227 return ERAR_BAD_DATA;
228
229 // Might be necessary if RARSetPassword is still called instead of
230 // open callback for RAR5 archives and if password is invalid.
231 if (Data->Arc.FailedHeaderDecryption)
232 return ERAR_BAD_PASSWORD;
233
234 return ERAR_END_ARCHIVE;
235 }
236 FileHeader *hd=&Data->Arc.FileHead;
237 if (Data->OpenMode==RAR_OM_LIST && hd->SplitBefore)
238 {
239 int Code=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL);
240 if (Code==0)
241 return RARReadHeaderEx(hArcData,D);
242 else
243 return Code;
244 }
245 wcsncpy(D->ArcNameW,Data->Arc.FileName,ASIZE(D->ArcNameW));
246 WideToChar(D->ArcNameW,D->ArcName,ASIZE(D->ArcName));
247
248 wcsncpy(D->FileNameW,hd->FileName,ASIZE(D->FileNameW));
249 WideToChar(D->FileNameW,D->FileName,ASIZE(D->FileName));
250#ifdef _WIN_ALL
251 CharToOemA(D->FileName,D->FileName);
252#endif
253
254 D->Flags=0;
255 if (hd->SplitBefore)
256 D->Flags|=RHDF_SPLITBEFORE;
257 if (hd->SplitAfter)
258 D->Flags|=RHDF_SPLITAFTER;
259 if (hd->Encrypted)
260 D->Flags|=RHDF_ENCRYPTED;
261 if (hd->Solid)
262 D->Flags|=RHDF_SOLID;
263 if (hd->Dir)
264 D->Flags|=RHDF_DIRECTORY;
265
266 D->PackSize=uint(hd->PackSize & 0xffffffff);

Callers 1

RARReadHeaderFunction · 0.85

Calls 10

MergeArchiveFunction · 0.85
RARProcessFileFunction · 0.85
WideToCharFunction · 0.85
wcsncpyzFunction · 0.85
RarErrorToDllFunction · 0.85
SearchBlockMethod · 0.80
GetHeaderTypeMethod · 0.80
GetDosMethod · 0.80
GetWinMethod · 0.80
SeekMethod · 0.45

Tested by

no test coverage detected