diff --git a/src/jobs.hpp b/src/jobs.hpp index 162a7c1..b881589 100644 --- a/src/jobs.hpp +++ b/src/jobs.hpp @@ -27,7 +27,7 @@ class KggTask { void info(const wchar_t* msg) const { fwprintf(stderr, L"[INFO] %s (%s)\n", msg, kgg_path_.filename().c_str()); } void info(const std::wstring& msg) const { info(msg.c_str()); } - void Execute(const Infra::kgm_ekey_db_t& ekey_db) const { + void Execute(const Infra::kgm_ekey_db_t& ekey_db, const std::wstring_view suffix) const { constexpr static std::array kMagicHeader{0x7C, 0xD5, 0x32, 0xEB, 0x86, 0x02, 0x7F, 0x4B, 0xA8, 0xAF, 0xA6, 0x8E, 0x0F, 0xFF, 0x99, 0x14}; @@ -70,7 +70,7 @@ class KggTask { kgg_stream_in.read(magic.data(), 4); qmc2->Decrypt(std::span(reinterpret_cast(magic.data()), 4), 0); auto real_ext = DetectRealExt(magic); - auto out_path = out_dir_ / std::format(L"{}_kgg-dec.{}", kgg_path_.stem().wstring(), real_ext); + auto out_path = out_dir_ / std::format(L"{}{}.{}", kgg_path_.stem().wstring(), suffix, real_ext); if (exists(out_path)) { warning(std::format(L"output file already exists: {}", out_path.filename().wstring())); @@ -117,7 +117,8 @@ class KggTask { class KggTaskQueue { public: - explicit KggTaskQueue(Infra::kgm_ekey_db_t ekey_db) : ekey_db_(std::move(ekey_db)) {} + explicit KggTaskQueue(Infra::kgm_ekey_db_t ekey_db, const std::wstring_view suffix) + : ekey_db_(std::move(ekey_db)), suffix_(suffix) {} void Push(std::unique_ptr task) { std::lock_guard lock(mutex_); @@ -160,12 +161,13 @@ class KggTaskQueue { private: bool thread_end_{false}; Infra::kgm_ekey_db_t ekey_db_; + std::wstring suffix_; void WorkerThreadBody() { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); std::unique_ptr task{nullptr}; while ((task = Pop())) { - task->Execute(ekey_db_); + task->Execute(ekey_db_, suffix_); } } diff --git a/src/main.cpp b/src/main.cpp index 150fee4..c8f2bca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,7 @@ int main() { } #endif - KggTaskQueue queue(ekey_db); + KggTaskQueue queue(ekey_db, file_suffix); auto thread_count = #ifndef NDEBUG 1;