| 1 | #include "rar.hpp" |
| 2 | |
| 3 | size_t Archive::ReadHeader() |
| 4 | { |
| 5 | // Once we failed to decrypt an encrypted block, there is no reason to |
| 6 | // attempt to do it further. We'll never be successful and only generate |
| 7 | // endless errors. |
| 8 | if (FailedHeaderDecryption) |
| 9 | return 0; |
| 10 | |
| 11 | CurBlockPos=Tell(); |
| 12 | |
| 13 | // Other developers asked us to initialize it to suppress "may be used |
| 14 | // uninitialized" warning in code below in some compilers. |
| 15 | size_t ReadSize=0; |
| 16 | |
| 17 | switch(Format) |
| 18 | { |
| 19 | #ifndef SFX_MODULE |
| 20 | case RARFMT14: |
| 21 | ReadSize=ReadHeader14(); |
| 22 | break; |
| 23 | #endif |
| 24 | case RARFMT15: |
| 25 | ReadSize=ReadHeader15(); |
| 26 | break; |
| 27 | case RARFMT50: |
| 28 | ReadSize=ReadHeader50(); |
| 29 | break; |
| 30 | } |
| 31 | |
| 32 | // It is important to check ReadSize>0 here, because it is normal |
| 33 | // for RAR2 and RAR3 archives without end of archive block to have |
| 34 | // NextBlockPos==CurBlockPos after the end of archive has reached. |
| 35 | if (ReadSize>0 && NextBlockPos<=CurBlockPos) |
| 36 | { |
| 37 | BrokenHeaderMsg(); |
| 38 | ReadSize=0; |
| 39 | } |
| 40 | |
| 41 | if (ReadSize==0) |
| 42 | CurHeaderType=HEAD_UNKNOWN; |
| 43 | |
| 44 | return ReadSize; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | size_t Archive::SearchBlock(HEADER_TYPE HeaderType) |
nothing calls this directly
no outgoing calls
no test coverage detected