Ejemplo n.º 1
0
// Delete all of the partly reconstructed files
bool Par1Repairer::DeleteIncompleteTargetFiles(void) {
	list<Par1RepairerSourceFile*>::iterator sf = verifylist.begin();

	// Iterate through each file in the verification list
	while (sf != verifylist.end()) {
		Par1RepairerSourceFile *sourcefile = *sf;
		if (sourcefile->GetTargetExists()) {
			DiskFile *targetfile = sourcefile->GetTargetFile();

			// Close and delete the file
			if (targetfile->IsOpen())
				targetfile->Close();
			targetfile->Delete();

			// Forget the file
			diskfilemap.Remove(targetfile);

			delete targetfile;

			// There is no target file
			sourcefile->SetTargetExists(false);
			sourcefile->SetTargetFile(0);
		}

		++sf;
	}

	return true;
}
Ejemplo n.º 2
0
bool Par1Repairer::RemoveParFiles(void) {
	if (noiselevel > CommandLine::nlSilent
			&& parlist.size() > 0) {
			cout << endl << "Purge par files." << endl;
	}

	for (list<string>::const_iterator s=parlist.begin(); s!=parlist.end(); ++s) {
		DiskFile *diskfile = new DiskFile;

		if (diskfile->Open(*s)) {
			if (noiselevel > CommandLine::nlSilent) {
				string name;
				string path;
				DiskFile::SplitFilename((*s), path, name);
				cout << "Remove \"" << name << "\"." << endl;
			}

			if (diskfile->IsOpen())
				diskfile->Close();
			diskfile->Delete();
		}

		delete diskfile;
	}

	return true;
}
Ejemplo n.º 3
0
// Verify that all of the reconstructed target files are now correct
bool Par1Repairer::VerifyTargetFiles(void) {
	bool finalresult = true;

	// Verify the target files in alphabetical order
//  sort(verifylist.begin(), verifylist.end(), SortSourceFilesByFileName);

	// Iterate through each file in the verification list
	for (list<Par1RepairerSourceFile*>::iterator sf = verifylist.begin();
			 sf != verifylist.end();
			 ++sf) {
		Par1RepairerSourceFile *sourcefile = *sf;
		DiskFile *targetfile = sourcefile->GetTargetFile();

		// Close the file
		if (targetfile->IsOpen())
			targetfile->Close();

		// Say we don't have a complete version of the file
		sourcefile->SetCompleteFile(0);

		// Re-open the target file
		if (!targetfile->Open()) {
			finalresult = false;
			continue;
		}

		// Verify the file again
		if (!VerifyDataFile(targetfile, sourcefile))
			finalresult = false;

		// Close the file again
		targetfile->Close();

		// Find out how much data we have found
		UpdateVerificationResults();
	}

	return finalresult;
}