| 207 | |
| 208 | |
| 209 | int 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); |
no test coverage detected