MCPcopy Create free account
hub / github.com/Parchive/par2cmdline / LoadRecoveryFile

Method LoadRecoveryFile

src/par1repairer.cpp:267–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267bool Par1Repairer::LoadRecoveryFile(std::string filename)
268{
269 // Skip the file if it has already been processed
270 if (diskfilemap.Find(filename) != 0)
271 {
272 return true;
273 }
274
275 DiskFile *diskfile = new DiskFile(sout, serr);
276
277 // Open the file
278 if (!diskfile->Open(filename))
279 {
280 // If we could not open the file, ignore the error and
281 // proceed to the next file
282 delete diskfile;
283 return true;
284 }
285
286 if (noiselevel > nlSilent)
287 {
288 std::string path;
289 std::string name;
290 DiskFile::SplitFilename(filename, path, name);
291 sout << "Loading \"" << name << "\"." << std::endl;
292 }
293
294 parlist.push_back(filename);
295
296 bool havevolume = false;
297 u32 volumenumber = 0;
298
299 // How big is the file
300 u64 filesize = diskfile->FileSize();
301 if (filesize >= sizeof(PAR1FILEHEADER))
302 {
303 // Allocate a buffer to read data into
304 size_t buffersize = (size_t)std::min((u64)1048576, filesize);
305 u8 *buffer = new u8[buffersize];
306
307 do
308 {
309 PAR1FILEHEADER fileheader;
310 if (!diskfile->Read(0, &fileheader, sizeof(fileheader)))
311 break;
312
313 // Is this really a PAR file?
314 if (fileheader.magic != par1_magic)
315 break;
316
317 // Is the version number correct?
318 if (fileheader.fileversion != 0x00010000)
319 break;
320
321 ignore16kfilehash = (fileheader.programversion == smartpar11);
322
323 // Prepare to carry out MD5 Hash check of the Control Hash
324 MD5Context context;

Callers

nothing calls this directly

Calls 10

FindMethod · 0.80
ReadMethod · 0.80
UpdateMethod · 0.80
FinalMethod · 0.80
SetLengthMethod · 0.80
SetLocationMethod · 0.80
OpenMethod · 0.45
FileSizeMethod · 0.45
CloseMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected