|
@@ -29,13 +29,17 @@ namespace LOTRO_DAT {
|
|
|
int iterated_files = 0;
|
|
|
|
|
|
dat->GetStatusModule().SetStatus(DatStatus::E_EXTRACTING);
|
|
|
- dat->GetStatusModule().SetPercentage(0);
|
|
|
+ dat->GetStatusModule().SetFinishedParts(0);
|
|
|
+ dat->GetStatusModule().SetTotalParts(dat->GetFileSystem().GetInitialisedFilesNumber());
|
|
|
+
|
|
|
dat->GetStatusModule().SetDebugMessage("Starting extracting files of type " + std::to_string(type) + ", this may take long time, please be patient!");
|
|
|
LOG(INFO) << "Extracting files by type " + std::to_string(type) + "to database...";
|
|
|
|
|
|
auto operation = dat->GetFileSystem().PerformOperationOnAllFiles([&iterated_files, &success_exported, this, type, &output_directory_path](std::shared_ptr<SubFile>& file) -> void {
|
|
|
iterated_files++;
|
|
|
- dat->GetStatusModule().SetPercentage(iterated_files * 100u / dat->GetFileSystem().GetInitialisedFilesNumber());
|
|
|
+ dat->GetStatusModule().SetFinishedParts(iterated_files);
|
|
|
+ dat->GetStatusModule().SetTotalParts(dat->GetFileSystem().GetInitialisedFilesNumber());
|
|
|
+
|
|
|
if ((file->FileType() & type) == NO_TYPE)
|
|
|
return;
|
|
|
|
|
@@ -57,7 +61,7 @@ namespace LOTRO_DAT {
|
|
|
});
|
|
|
|
|
|
LOG(INFO) << "Extracting files: successfully exported " << success_exported << " files";
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<int>(success_exported, SUCCESS);
|
|
|
}
|
|
|
|
|
@@ -72,19 +76,20 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
DatOperationResult<> DatExporter::ExtractFileById(long long file_id, std::string output_filename) {
|
|
|
dat->GetStatusModule().SetStatus(DatStatus::E_EXTRACTING);
|
|
|
- dat->GetStatusModule().SetPercentage(0);
|
|
|
+ dat->GetStatusModule().SetFinishedParts(0);
|
|
|
+ dat->GetStatusModule().SetTotalParts(1);
|
|
|
dat->GetStatusModule().SetDebugMessage("Extracting file " + std::to_string(file_id) + " to file " + output_filename);
|
|
|
|
|
|
auto operation_GetFile = dat->GetFileSystem().GetFile(file_id);
|
|
|
if (operation_GetFile.result == ERROR) {
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYID: File not found! id = " + std::to_string(file_id));
|
|
|
}
|
|
|
std::shared_ptr<SubFile> file = operation_GetFile.value;
|
|
|
|
|
|
auto operation_GetFileData = dat->GetFileSystem().GetFileData(*file, 8);
|
|
|
if (operation_GetFileData.result == ERROR) {
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYID: Can't get data for id = " + std::to_string(file_id));
|
|
|
}
|
|
|
|
|
@@ -97,7 +102,7 @@ namespace LOTRO_DAT {
|
|
|
else
|
|
|
result = export_data.binary_data.WriteToFile(output_filename + file->Extension());
|
|
|
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
if (!result)
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYID: Cannot write to file" + output_filename + file->Extension());
|
|
|
|
|
@@ -121,7 +126,8 @@ namespace LOTRO_DAT {
|
|
|
return DatOperationResult<int>(0, ERROR, "EXTRACTALLBYTYPETODB: database is nullptr");
|
|
|
|
|
|
dat->GetStatusModule().SetStatus(DatStatus::E_EXTRACTING);
|
|
|
- dat->GetStatusModule().SetPercentage(0);
|
|
|
+ dat->GetStatusModule().SetFinishedParts(0);
|
|
|
+ dat->GetStatusModule().SetTotalParts(dat->GetFileSystem().GetInitialisedFilesNumber());
|
|
|
dat->GetStatusModule().SetDebugMessage("Initialising extraction of files by type " + std::to_string(type) + "to database... This may take long time, please be patient!\"");
|
|
|
LOG(INFO) << "Extracting files by type " + std::to_string(type) + "to database...";
|
|
|
|
|
@@ -130,7 +136,7 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
auto operation = dat->GetFileSystem().PerformOperationOnAllFiles([&success_exported, &iterated_files, this, type, db](std::shared_ptr<SubFile>& file) {
|
|
|
iterated_files++;
|
|
|
- dat->GetStatusModule().SetPercentage(iterated_files * 100u / dat->GetFileSystem().GetInitialisedFilesNumber());
|
|
|
+ dat->GetStatusModule().SetFinishedParts(iterated_files);
|
|
|
|
|
|
if ((file->FileType() & type) == NO_TYPE)
|
|
|
return;
|
|
@@ -146,12 +152,10 @@ namespace LOTRO_DAT {
|
|
|
});
|
|
|
|
|
|
LOG(INFO) << "Extracting files: successfully exported " << success_exported << " files";
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<int>(success_exported, SUCCESS);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
* \author Ivan Arkhipov
|
|
|
* \date 21.10.2018
|
|
@@ -165,19 +169,20 @@ namespace LOTRO_DAT {
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYIDTODB: database is nullptr");
|
|
|
|
|
|
dat->GetStatusModule().SetStatus(DatStatus::E_EXTRACTING);
|
|
|
- dat->GetStatusModule().SetPercentage(50);
|
|
|
+ dat->GetStatusModule().SetFinishedParts(0);
|
|
|
+ dat->GetStatusModule().SetTotalParts(1);
|
|
|
LOG(INFO) << "Extracting file with id = " << file_id << "to database...";
|
|
|
|
|
|
auto operation_GetFile = dat->GetFileSystem().GetFile(file_id);
|
|
|
if (operation_GetFile.result == ERROR) {
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYIDTODB: File not found! id = " + std::to_string(file_id));
|
|
|
}
|
|
|
std::shared_ptr<SubFile> file = operation_GetFile.value;
|
|
|
|
|
|
auto operation_GetFileData = dat->GetFileSystem().GetFileData(*file, 8);
|
|
|
if (operation_GetFileData.result == ERROR) {
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYIDTODB: Can't get data for id = " + std::to_string(file_id));
|
|
|
}
|
|
|
|
|
@@ -185,7 +190,7 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
bool result = db->PushFile(export_data);
|
|
|
|
|
|
- dat->GetStatusModule().ClearAll();
|
|
|
+ dat->GetStatusModule().SetDefaultStatus();
|
|
|
if (!result)
|
|
|
return DatOperationResult<>(ERROR, "EXTRACTFILEBYIDTODB: Cannot export file" + std::to_string(file_id));
|
|
|
|