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

Method Read

Libraries/unrar/file.cpp:370–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368
369
370int File::Read(void *Data,size_t Size)
371{
372 int64 FilePos=0; // Initialized only to suppress some compilers warning.
373
374 if (IgnoreReadErrors)
375 FilePos=Tell();
376 int ReadSize;
377 while (true)
378 {
379 ReadSize=DirectRead(Data,Size);
380 if (ReadSize==-1)
381 {
382 ErrorType=FILE_READERROR;
383 if (AllowExceptions)
384 if (IgnoreReadErrors)
385 {
386 ReadSize=0;
387 for (size_t I=0;I<Size;I+=512)
388 {
389 Seek(FilePos+I,SEEK_SET);
390 size_t SizeToRead=Min(Size-I,512);
391 int ReadCode=DirectRead(Data,SizeToRead);
392 ReadSize+=(ReadCode==-1) ? 512:ReadCode;
393 }
394 }
395 else
396 {
397 if (HandleType==FILE_HANDLENORMAL && ErrHandler.AskRepeatRead(FileName))
398 continue;
399 ErrHandler.ReadError(FileName);
400 }
401 }
402 break;
403 }
404 return ReadSize; // It can return -1 only if AllowExceptions is disabled.
405}
406
407
408// Returns -1 in case of error.

Callers 14

RestoreMethod · 0.45
ReadHeaderMethod · 0.45
RestoreMethod · 0.45
RecVolumesRestoreFunction · 0.45
RecVolumesTestFunction · 0.45
getwstrFunction · 0.45
UnpReadMethod · 0.45
ReadTextFileFunction · 0.45
ReadHeader15Method · 0.45
ReadHeader50Method · 0.45
ReadHeader14Method · 0.45
ListFileHeaderFunction · 0.45

Calls 2

AskRepeatReadMethod · 0.80
ReadErrorMethod · 0.80

Tested by

no test coverage detected