MCPcopy Create free account
hub / github.com/amule-project/amule / LoadPartFile

Method LoadPartFile

src/PartFile.cpp:384–817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382
383
384uint8 CPartFile::LoadPartFile(const CPath& in_directory, const CPath& filename, bool from_backup, bool getsizeonly)
385{
386 bool isnewstyle = false;
387 uint8 version,partmettype=PMT_UNKNOWN;
388
389 std::map<uint16, Gap_Struct*> gap_map; // Slugfiller
390 transferred = 0;
391
392 m_partmetfilename = filename;
393 m_CorruptionBlackBox->SetPartFileInfo(GetFileName().GetPrintable(), m_partmetfilename.RemoveAllExt().GetPrintable());
394 m_filePath = in_directory;
395 m_fullname = m_filePath.JoinPaths(m_partmetfilename);
396 m_PartPath = m_fullname.RemoveExt();
397
398 // readfile data form part.met file
399 CPath curMetFilename = m_fullname;
400 if (from_backup) {
401 curMetFilename = curMetFilename.AppendExt(PARTMET_BAK_EXT);
402 AddLogLineN(CFormat( _("Trying to load backup of met-file from %s") )
403 % curMetFilename );
404 }
405
406 try {
407 CFile metFile(curMetFilename, CFile::read);
408 if (!metFile.IsOpened()) {
409 AddLogLineN(CFormat( _("ERROR: Failed to open part.met file: %s ==> %s") )
410 % curMetFilename
411 % GetFileName() );
412
413 return false;
414 } else if (metFile.GetLength() == 0) {
415 AddLogLineN(CFormat( _("ERROR: part.met file is 0 size: %s ==> %s") )
416 % m_partmetfilename
417 % GetFileName() );
418
419 return false;
420 }
421
422 version = metFile.ReadUInt8();
423 if (version != PARTFILE_VERSION && version != PARTFILE_SPLITTEDVERSION && version != PARTFILE_VERSION_LARGEFILE){
424 metFile.Close();
425 //if (version == 83) return ImportShareazaTempFile(...)
426 AddLogLineN(CFormat( _("ERROR: Invalid part.met file version: %s ==> %s") )
427 % m_partmetfilename
428 % GetFileName() );
429 return false;
430 }
431
432 isnewstyle = (version == PARTFILE_SPLITTEDVERSION);
433 partmettype = isnewstyle ? PMT_SPLITTED : PMT_DEFAULTOLD;
434
435 if (version == PARTFILE_VERSION) {// Do we still need this check ?
436 uint8 test[4]; // It will fail for certain files.
437 metFile.Seek(24, wxFromStart);
438 metFile.Read(test,4);
439
440 metFile.Seek(1, wxFromStart);
441 if (test[0]==0 && test[1]==0 && test[2]==2 && test[3]==1) {

Callers 2

LoadMetFilesMethod · 0.80
performConvertToeMuleMethod · 0.80

Calls 15

CFormatClass · 0.85
GetTickCount64Function · 0.85
SetPartFileInfoMethod · 0.80
GetPrintableMethod · 0.80
RemoveAllExtMethod · 0.80
JoinPathsMethod · 0.80
RemoveExtMethod · 0.80
AppendExtMethod · 0.80
ReadUInt8Method · 0.80
SeekMethod · 0.80
ReadUInt32Method · 0.80
GetNameIDMethod · 0.80

Tested by

no test coverage detected