| 138 | |
| 139 | |
| 140 | bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) |
| 141 | { |
| 142 | wchar ArcName[NM]; |
| 143 | wcsncpyz(ArcName,Name,ASIZE(ArcName)); |
| 144 | |
| 145 | wchar *Num=GetVolNumPart(ArcName); |
| 146 | while (Num>ArcName && IsDigit(*(Num-1))) |
| 147 | Num--; |
| 148 | if (Num==ArcName) |
| 149 | return false; // Numeric part is missing or entire volume name is numeric, not possible for RAR or REV volume. |
| 150 | wcsncpyz(Num,L"*.*",ASIZE(ArcName)-(Num-ArcName)); |
| 151 | |
| 152 | wchar FirstVolName[NM]; |
| 153 | *FirstVolName=0; |
| 154 | |
| 155 | int64 RecFileSize=0; |
| 156 | |
| 157 | FindFile VolFind; |
| 158 | VolFind.SetMask(ArcName); |
| 159 | FindData fd; |
| 160 | uint FoundRecVolumes=0; |
| 161 | while (VolFind.Next(&fd)) |
| 162 | { |
| 163 | Wait(); |
| 164 | |
| 165 | Archive *Vol=new Archive(Cmd); |
| 166 | int ItemPos=-1; |
| 167 | if (Vol->WOpen(fd.Name)) |
| 168 | { |
| 169 | if (CmpExt(fd.Name,L"rev")) |
| 170 | { |
| 171 | uint RecNum=ReadHeader(Vol,FoundRecVolumes==0); |
| 172 | if (RecNum!=0) |
| 173 | { |
| 174 | if (FoundRecVolumes==0) |
| 175 | RecFileSize=Vol->FileLength(); |
| 176 | |
| 177 | ItemPos=RecNum; |
| 178 | FoundRecVolumes++; |
| 179 | } |
| 180 | } |
| 181 | else |
| 182 | if (Vol->IsArchive(true) && (Vol->SFXSize>0 || CmpExt(fd.Name,L"rar"))) |
| 183 | { |
| 184 | if (!Vol->Volume && !Vol->BrokenHeader) |
| 185 | { |
| 186 | uiMsg(UIERROR_NOTVOLUME,ArcName); |
| 187 | return false; |
| 188 | } |
| 189 | // We work with archive as with raw data file, so we do not want |
| 190 | // to spend time to QOpen I/O redirection. |
| 191 | Vol->QOpenUnload(); |
| 192 | |
| 193 | Vol->Seek(0,SEEK_SET); |
| 194 | |
| 195 | // RAR volume found. Get its number, store the handle in appropriate |
| 196 | // array slot, clean slots in between if we had to grow the array. |
| 197 | wchar *Num=GetVolNumPart(fd.Name); |
no test coverage detected