| 43 | |
| 44 | |
| 45 | void RecVolumesTest(RAROptions *Cmd,Archive *Arc,const wchar *Name) |
| 46 | { |
| 47 | wchar RevName[NM]; |
| 48 | *RevName=0; |
| 49 | if (Arc!=NULL) |
| 50 | { |
| 51 | // We received .rar or .exe volume as a parameter, trying to find |
| 52 | // the matching .rev file number 1. |
| 53 | bool NewNumbering=Arc->NewNumbering; |
| 54 | |
| 55 | wchar ArcName[NM]; |
| 56 | wcsncpyz(ArcName,Name,ASIZE(ArcName)); |
| 57 | |
| 58 | wchar *VolNumStart=VolNameToFirstName(ArcName,ArcName,ASIZE(ArcName),NewNumbering); |
| 59 | wchar RecVolMask[NM]; |
| 60 | wcsncpyz(RecVolMask,ArcName,ASIZE(RecVolMask)); |
| 61 | size_t BaseNamePartLength=VolNumStart-ArcName; |
| 62 | wcsncpyz(RecVolMask+BaseNamePartLength,L"*.rev",ASIZE(RecVolMask)-BaseNamePartLength); |
| 63 | |
| 64 | FindFile Find; |
| 65 | Find.SetMask(RecVolMask); |
| 66 | FindData RecData; |
| 67 | |
| 68 | while (Find.Next(&RecData)) |
| 69 | { |
| 70 | wchar *Num=GetVolNumPart(RecData.Name); |
| 71 | if (*Num!='1') // Name must have "0...01" numeric part. |
| 72 | continue; |
| 73 | bool FirstVol=true; |
| 74 | while (--Num>=RecData.Name && IsDigit(*Num)) |
| 75 | if (*Num!='0') |
| 76 | { |
| 77 | FirstVol=false; |
| 78 | break; |
| 79 | } |
| 80 | if (FirstVol) |
| 81 | { |
| 82 | wcsncpyz(RevName,RecData.Name,ASIZE(RevName)); |
| 83 | Name=RevName; |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | if (*RevName==0) // First .rev file not found. |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | File RevFile; |
| 92 | if (!RevFile.Open(Name)) |
| 93 | { |
| 94 | ErrHandler.OpenErrorMsg(Name); // It also sets RARX_OPEN. |
| 95 | return; |
| 96 | } |
| 97 | mprintf(L"\n"); |
| 98 | byte Sign[REV5_SIGN_SIZE]; |
| 99 | bool Rev5=RevFile.Read(Sign,REV5_SIGN_SIZE)==REV5_SIGN_SIZE && memcmp(Sign,REV5_SIGN,REV5_SIGN_SIZE)==0; |
| 100 | RevFile.Close(); |
| 101 | if (Rev5) |
| 102 | { |
no test coverage detected