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

Function RecVolumesTest

Libraries/unrar/recvol.cpp:45–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44
45void 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 {

Callers 1

ExtractArchiveMethod · 0.85

Calls 12

wcsncpyzFunction · 0.85
VolNameToFirstNameFunction · 0.85
GetVolNumPartFunction · 0.85
IsDigitFunction · 0.85
SetMaskMethod · 0.80
NextMethod · 0.80
OpenErrorMsgMethod · 0.80
mprintfFunction · 0.70
OpenMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45
TestMethod · 0.45

Tested by

no test coverage detected