Sfoglia il codice sorgente

DatFileIO & DatOperationResult code refactoring

Ivan Arkhipov 6 anni fa
parent
commit
7206c0cfa0
2 ha cambiato i file con 3 aggiunte e 10 eliminazioni
  1. 1 5
      include/DatOperationResult.h
  2. 2 5
      src/DatFileIO.cpp

+ 1 - 5
include/DatOperationResult.h

@@ -20,11 +20,7 @@ namespace LOTRO_DAT {
 
         DatOperationResult(RESULT result_, std::string msg_) : result(result_), msg(std::move(msg_)) {}
 
-        DatOperationResult &operator=(const DatOperationResult &other) {
-            result = other.result;
-            msg = other.msg;
-            return *this;
-        }
+        DatOperationResult &operator=(const DatOperationResult &other) = default;
 
         RESULT result;
         std::string msg;

+ 2 - 5
src/DatFileIO.cpp

@@ -29,11 +29,11 @@ namespace LOTRO_DAT {
                                              root_directory_(nullptr), actual_dat_size_(0) {
     }
 
+
     //------------------------------------------------//
     // INIT SECTION
     //------------------------------------------------//
 
-
     DatOperationResult DatFileIO::Init(const std::string &filename) {
         LOG(INFO) << "Initializing IO: " << filename;
 
@@ -205,13 +205,12 @@ namespace LOTRO_DAT {
         return DatOperationResult(DatOperationResult::SUCCESS, "Data writing successful.");
     }
 
+
     //------------------------------------------------//
     // DEINIT SECTION
     //------------------------------------------------//
 
     DatOperationResult DatFileIO::DeInit() {
-        UpdateHeader();
-
         if (file_handler_ != nullptr) {
             fclose(file_handler_);
         }
@@ -233,7 +232,6 @@ namespace LOTRO_DAT {
         return DatOperationResult(DatOperationResult::SUCCESS, "File deinitialisation successfull");
     }
 
-
     DatOperationResult DatFileIO::ModifyFragmentationJournal() {
         if (fragmentation_journal_size == 0)
             return DatOperationResult(DatOperationResult::SUCCESS,
@@ -261,7 +259,6 @@ namespace LOTRO_DAT {
         return DatOperationResult(DatOperationResult::SUCCESS, "Fragmentation journal patched successfully!");
     }
 
-
     DatOperationResult DatFileIO::UpdateHeader() {
         LOG(DEBUG) << "Updating header";
         WriteData(BinaryData::FromNumber<4>(constant1), 4, 0x100);