diff --git a/inc/ffshit/filesystem/platform/base.h b/inc/ffshit/filesystem/platform/base.h index 2766e52..3b7ad74 100644 --- a/inc/ffshit/filesystem/platform/base.h +++ b/inc/ffshit/filesystem/platform/base.h @@ -16,7 +16,7 @@ class Base { Base() { } - virtual void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) = 0; + virtual void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector parts_to_extract = {}) = 0; virtual const Directory::Ptr get_root() const = 0; virtual ~Base() { } diff --git a/inc/ffshit/filesystem/platform/egold_ce.h b/inc/ffshit/filesystem/platform/egold_ce.h index b1c1038..c89d269 100644 --- a/inc/ffshit/filesystem/platform/egold_ce.h +++ b/inc/ffshit/filesystem/platform/egold_ce.h @@ -20,7 +20,7 @@ class EGOLD_CE : public Base { return std::make_shared(partitions); } - void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final; + void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector parts_to_extract = {}) override final; const Directory::Ptr get_root() const override final; private: @@ -73,7 +73,7 @@ class EGOLD_CE : public Base { std::vector recourse_protector; - void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data); + void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract); void print_block_header(const FFSBlock &block); void print_file_header(const FFSFile &file); diff --git a/inc/ffshit/filesystem/platform/sgold.h b/inc/ffshit/filesystem/platform/sgold.h index 0de4d99..325b75d 100644 --- a/inc/ffshit/filesystem/platform/sgold.h +++ b/inc/ffshit/filesystem/platform/sgold.h @@ -18,7 +18,7 @@ class SGOLD : public Base { return std::make_shared(partitions); } - void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final; + void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector parts_to_extract = {}) override final; const Directory::Ptr get_root() const override final; private: @@ -71,7 +71,7 @@ class SGOLD : public Base { bool prototype_6000; - void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data); + void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract); void scan(const std::string &block_name, FSBlocksMap &ffs_map, Directory::Ptr dir, const FileHeader &header, bool skip_broken = false, std::string path = "/"); void read_recurse(FSBlocksMap &ffs_map, RawData &data, uint16_t next_id); diff --git a/inc/ffshit/filesystem/platform/sgold2.h b/inc/ffshit/filesystem/platform/sgold2.h index 3208667..7fc376a 100644 --- a/inc/ffshit/filesystem/platform/sgold2.h +++ b/inc/ffshit/filesystem/platform/sgold2.h @@ -16,7 +16,7 @@ class SGOLD2 : public Base { return std::make_shared(partitions); } - void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final; + void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector parts_to_extract = {}) override final; const Directory::Ptr get_root() const override final; private: @@ -67,7 +67,7 @@ class SGOLD2 : public Base { std::vector recourse_protector; static void print_fit_header(const SGOLD2::FITHeader &header); - void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data); + void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract); static void print_file_header(const FileHeader &header); static void print_file_part(const FilePart &part); diff --git a/inc/ffshit/filesystem/platform/sgold2_elka.h b/inc/ffshit/filesystem/platform/sgold2_elka.h index e6524b1..f2e45fa 100644 --- a/inc/ffshit/filesystem/platform/sgold2_elka.h +++ b/inc/ffshit/filesystem/platform/sgold2_elka.h @@ -16,7 +16,7 @@ class SGOLD2_ELKA : public Base { return std::make_shared(partitions); } - void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final; + void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector parts_to_extract = {}) override final; const Directory::Ptr get_root() const override final; private: @@ -77,7 +77,7 @@ class SGOLD2_ELKA : public Base { std::vector recourse_protector; - void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data); + void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract); static void print_fit_header(const SGOLD2_ELKA::FITHeader &header); static void print_dir_header(const DirHeader &header); diff --git a/src/filesystem/platform/egold_ce.cpp b/src/filesystem/platform/egold_ce.cpp index 9fa6c33..ea0df32 100644 --- a/src/filesystem/platform/egold_ce.cpp +++ b/src/filesystem/platform/egold_ce.cpp @@ -15,8 +15,8 @@ EGOLD_CE::EGOLD_CE(Partitions::Partitions::Ptr partitions) : partitions(partitio root_dir = Directory::build(ROOT_NAME, "/"); } -void EGOLD_CE::load(bool skip_broken, bool skip_dup, bool dump_data) { - parse_FIT(skip_broken, skip_dup, dump_data); +void EGOLD_CE::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { + parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract); } const Directory::Ptr EGOLD_CE::get_root() const { @@ -67,7 +67,7 @@ void EGOLD_CE::print_data(const FFSBlock &block) { } } -void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { +void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { const auto &part_map = partitions->get_partitions(); for (const auto &pair : part_map) { @@ -76,6 +76,24 @@ void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { const auto & part_blocks = part_info.get_blocks(); if (part_name.find("FFS") != std::string::npos) { + if (parts_to_extract.size() != 0) { + bool is_extract = false; + + for (const auto &part_to_extract : parts_to_extract) { + if (part_name == part_to_extract) { + is_extract = true; + + break; + } + } + + if (!is_extract) { + Log::Logger::warn("Partition {} excluded", part_name); + + continue; + } + } + Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size()); } else { continue; diff --git a/src/filesystem/platform/sgold.cpp b/src/filesystem/platform/sgold.cpp index 065c2e0..bd04f6b 100644 --- a/src/filesystem/platform/sgold.cpp +++ b/src/filesystem/platform/sgold.cpp @@ -77,8 +77,8 @@ SGOLD::SGOLD(Partitions::Partitions::Ptr partitions) : partitions(partitions), p root_dir = Directory::build(ROOT_NAME, "/"); } -void SGOLD::load(bool skip_broken, bool skip_dup, bool dump_data) { - parse_FIT(skip_broken, skip_dup, dump_data); +void SGOLD::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { + parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract); } const Directory::Ptr SGOLD::get_root() const { @@ -175,7 +175,7 @@ void SGOLD::print_data(const FFSBlock &block) { } } -void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { +void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { const auto &part_map = partitions->get_partitions(); for (const auto &pair : part_map) { @@ -184,6 +184,24 @@ void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { const auto & part_blocks = part_info.get_blocks(); if (part_name.find("FFS") != std::string::npos) { + if (parts_to_extract.size() != 0) { + bool is_extract = false; + + for (const auto &part_to_extract : parts_to_extract) { + if (part_name == part_to_extract) { + is_extract = true; + + break; + } + } + + if (!is_extract) { + Log::Logger::warn("Partition {} excluded", part_name); + + continue; + } + } + Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size()); } else { continue; diff --git a/src/filesystem/platform/sgold2.cpp b/src/filesystem/platform/sgold2.cpp index b64822b..37e5210 100644 --- a/src/filesystem/platform/sgold2.cpp +++ b/src/filesystem/platform/sgold2.cpp @@ -24,8 +24,8 @@ SGOLD2::SGOLD2(Partitions::Partitions::Ptr partitions) : partitions(partitions) root_dir = Directory::build(ROOT_NAME, "/"); } -void SGOLD2::load(bool skip_broken, bool skip_dup, bool dump_data) { - parse_FIT(skip_broken, skip_dup, dump_data); +void SGOLD2::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { + parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract); } const Directory::Ptr SGOLD2::get_root() const { @@ -164,7 +164,7 @@ SGOLD2::FilePart SGOLD2::read_file_part(const RawData &data) { return part; } -void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { +void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { const auto &part_map = partitions->get_partitions(); for (const auto &pair : part_map) { @@ -173,6 +173,24 @@ void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { const auto & part_blocks = part_info.get_blocks(); if (part_name.find("FFS") != std::string::npos) { + if (parts_to_extract.size() != 0) { + bool is_extract = false; + + for (const auto &part_to_extract : parts_to_extract) { + if (part_name == part_to_extract) { + is_extract = true; + + break; + } + } + + if (!is_extract) { + Log::Logger::warn("Partition {} excluded", part_name); + + continue; + } + } + Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size()); } else { continue; diff --git a/src/filesystem/platform/sgold2_elka.cpp b/src/filesystem/platform/sgold2_elka.cpp index 1375db1..72cf272 100644 --- a/src/filesystem/platform/sgold2_elka.cpp +++ b/src/filesystem/platform/sgold2_elka.cpp @@ -16,8 +16,8 @@ SGOLD2_ELKA::SGOLD2_ELKA(Partitions::Partitions::Ptr partitions) : partitions(pa root_dir = Directory::build(ROOT_NAME, "/"); } -void SGOLD2_ELKA::load(bool skip_broken, bool skip_dup, bool dump_data) { - parse_FIT(skip_broken, skip_dup, dump_data); +void SGOLD2_ELKA::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { + parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract); } const Directory::Ptr SGOLD2_ELKA::get_root() const { @@ -162,7 +162,7 @@ void SGOLD2_ELKA::print_data(const FFSBlock &block) { } } -void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { +void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector parts_to_extract) { const auto &part_map = partitions->get_partitions(); // auto check_header = [](const FITHeader &header, uint32_t block_size) -> bool { @@ -210,6 +210,24 @@ void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) { const auto & part_blocks = part_info.get_blocks(); if (part_name.find("FFS") != std::string::npos) { + if (parts_to_extract.size() != 0) { + bool is_extract = false; + + for (const auto &part_to_extract : parts_to_extract) { + if (part_name == part_to_extract) { + is_extract = true; + + break; + } + } + + if (!is_extract) { + Log::Logger::warn("Partition {} excluded", part_name); + + continue; + } + } + Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size()); } else { continue;