~ubuntu-branches/ubuntu/vivid/unrar-nonfree/vivid

« back to all changes in this revision

Viewing changes to recvol5.cpp

  • Committer: Package Import Robot
  • Author(s): Martin Meredith
  • Date: 2015-02-03 12:58:01 UTC
  • mfrom: (1.1.18) (5.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20150203125801-od6ev8cqy1er51vz
Tags: 1:5.2.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
        {
171
171
          if (!Vol->Volume && !Vol->BrokenHeader)
172
172
          {
173
 
            Log(ArcName,St(MNotVolume),ArcName);
 
173
            uiMsg(UIERROR_NOTVOLUME,ArcName);
174
174
            return false;
175
175
          }
176
176
          // We work with archive as with raw data file, so we do not want
197
197
          ItemPos=VolNum-1;
198
198
 
199
199
          if (*FirstVolName==0)
200
 
            VolNameToFirstName(fd.Name,FirstVolName,true);
 
200
            VolNameToFirstName(fd.Name,FirstVolName,ASIZE(FirstVolName),true);
201
201
        }
202
202
    }
203
203
    if (ItemPos==-1)
213
213
      }
214
214
  }
215
215
 
216
 
#ifndef SILENT
217
216
  if (!Silent || FoundRecVolumes!=0)
218
 
  {
219
 
    mprintf(St(MRecVolFound),FoundRecVolumes);
220
 
  }
221
 
#endif
 
217
    uiMsg(UIMSG_RECVOLFOUND,FoundRecVolumes);
222
218
  if (FoundRecVolumes==0)
223
219
    return false;
224
220
 
225
 
  mprintf(St(MCalcCRCAllVol));
 
221
  uiMsg(UIMSG_RECVOLCALCCHECKSUM);
226
222
 
227
223
  MissingVolumes=0;
228
224
  for (uint I=0;I<TotalCount;I++)
230
226
    RecVolItem *Item=&RecItems[I];
231
227
    if (Item->f!=NULL)
232
228
    {
233
 
      mprintf(L"\n%s",Item->Name);
 
229
      uiMsg(UIMSG_STRING,Item->Name);
 
230
 
234
231
      uint RevCRC;
235
232
      CalcFileSum(Item->f,&RevCRC,NULL,Cmd->Threads,INT64NDF,CALCFSUM_CURPOS);
236
233
      Item->Valid=RevCRC==Item->CRC;
237
234
      if (!Item->Valid)
238
235
      {
239
 
        mprintf(St(MCRCFailed),Item->Name);
 
236
        uiMsg(UIMSG_CHECKSUM,Item->Name);
 
237
 
240
238
        // Close only corrupt REV volumes here. We'll close and rename corrupt
241
239
        // RAR volumes later, if we'll know that recovery is possible.
242
240
        if (I>=DataCount)
251
249
      MissingVolumes++;
252
250
  }
253
251
 
254
 
  mprintf(St(MRecVolMissing),MissingVolumes);
 
252
  uiMsg(UIMSG_RECVOLMISSING,MissingVolumes);
255
253
 
256
254
  if (MissingVolumes==0)
257
255
  {
258
 
    mprintf(St(MRecVolAllExist));
 
256
    uiMsg(UIERROR_RECVOLALLEXIST);
259
257
    return false;
260
258
  }
261
259
 
262
260
  if (MissingVolumes>FoundRecVolumes)
263
261
  {
264
 
    mprintf(St(MRecVolCannotFix));
 
262
    uiMsg(UIERROR_RECVOLFOUND,FoundRecVolumes); // Intentionally not displayed in console mode.
 
263
    uiMsg(UIERROR_RECVOLCANNOTFIX);
265
264
    return false;
266
265
  }
267
266
 
268
 
  mprintf(St(MReconstructing));
 
267
  uiMsg(UIMSG_RECONSTRUCTING);
269
268
 
270
269
  // Create missing and rename bad volumes.
 
270
  uint64 MaxVolSize=0;
271
271
  for (uint I=0;I<DataCount;I++)
272
272
  {
273
273
    RecVolItem *Item=&RecItems[I];
 
274
    if (Item->FileSize>MaxVolSize)
 
275
      MaxVolSize=Item->FileSize;
274
276
    if (Item->f!=NULL && !Item->Valid)
275
277
    {
276
278
      Item->f->Close();
278
280
      wchar NewName[NM];
279
281
      wcscpy(NewName,Item->Name);
280
282
      wcscat(NewName,L".bad");
281
 
#ifndef SILENT
282
 
      mprintf(St(MBadArc),Item->Name);
283
 
      mprintf(St(MRenaming),Item->Name,NewName);
284
 
#endif
 
283
 
 
284
      uiMsg(UIMSG_BADARCHIVE,Item->Name);
 
285
      uiMsg(UIMSG_RENAMING,Item->Name,NewName);
285
286
      RenameFile(Item->Name,NewName);
286
287
      delete Item->f;
287
288
      Item->f=NULL;
290
291
    if (Item->New=(Item->f==NULL))
291
292
    {
292
293
      wcsncpyz(Item->Name,FirstVolName,ASIZE(Item->Name));
293
 
      mprintf(St(MCreating),Item->Name);
 
294
      uiMsg(UIMSG_CREATING,Item->Name);
 
295
      uiMsg(UIEVENT_NEWARCHIVE,Item->Name);
294
296
      File *NewVol=new File;
295
297
      bool UserReject;
296
 
      if (!FileCreate(Cmd,NewVol,Item->Name,ASIZE(Item->Name),Cmd->Overwrite,&UserReject))
 
298
      if (!FileCreate(Cmd,NewVol,Item->Name,ASIZE(Item->Name),&UserReject))
297
299
      {
298
300
        if (!UserReject)
299
 
          ErrHandler.CreateErrorMsg(NULL,Item->Name);
 
301
          ErrHandler.CreateErrorMsg(Item->Name);
300
302
        ErrHandler.Exit(UserReject ? RARX_USERBREAK:RARX_CREATE);
301
303
      }
302
304
      NewVol->Prealloc(Item->FileSize);
367
369
      if (ReadSize>MaxRead)
368
370
        MaxRead=ReadSize;
369
371
 
370
 
      ProcessRS(Cmd,I,B,MaxRead,false);
 
372
      // We can have volumes of different size. Let's use data chunk
 
373
      // for largest volume size.
 
374
      uint DataToProcess=(uint)Min(RecBufferSize,MaxVolSize-ProcessedSize);
 
375
      ProcessRS(Cmd,I,B,DataToProcess,false);
371
376
    }
372
377
    if (MaxRead==0)
373
378
      break;
381
386
        Item->FileSize-=WriteSize;
382
387
      }
383
388
 
384
 
#ifndef SILENT
385
389
    int CurPercent=ToPercent(ProcessedSize,RecFileSize);
386
390
    if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
387
391
    {
388
 
      mprintf(L"\b\b\b\b%3d%%",CurPercent);
 
392
      uiProcessProgress("RV",ProcessedSize,RecFileSize);
389
393
      LastPercent=CurPercent;
390
394
    }
391
395
    ProcessedSize+=MaxRead;
392
 
#endif
393
396
  }
394
397
 
395
398
  for (uint I=0;I<TotalCount;I++)
404
407
  if (!Silent && !Cmd->DisableDone)
405
408
    mprintf(St(MDone));
406
409
#endif
407
 
  return(true);
 
410
  return true;
408
411
}
409
412
 
410
413