mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 00:38:58 +00:00
Change filename format to better match GM9's
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cryptopp/rsa.h>
|
#include <cryptopp/rsa.h>
|
||||||
#include <cryptopp/sha.h>
|
#include <cryptopp/sha.h>
|
||||||
|
#include <fmt/format.h>
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
@@ -164,6 +165,12 @@ u16 TitleMetadata::GetTitleVersion() const {
|
|||||||
return tmd_body.title_version;
|
return tmd_body.title_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TitleMetadata::GetTitleVersionString() const {
|
||||||
|
const auto title_version = static_cast<u16>(tmd_body.title_version);
|
||||||
|
return fmt::format("{}.{}.{}", (title_version >> 10) & 0x3F, (title_version >> 4) & 0x3F,
|
||||||
|
title_version & 0xF);
|
||||||
|
}
|
||||||
|
|
||||||
u64 TitleMetadata::GetSystemVersion() const {
|
u64 TitleMetadata::GetSystemVersion() const {
|
||||||
return tmd_body.system_version;
|
return tmd_body.system_version;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
u64 GetTitleID() const;
|
u64 GetTitleID() const;
|
||||||
u32 GetTitleType() const;
|
u32 GetTitleType() const;
|
||||||
u16 GetTitleVersion() const;
|
u16 GetTitleVersion() const;
|
||||||
|
std::string GetTitleVersionString() const;
|
||||||
u64 GetSystemVersion() const;
|
u64 GetSystemVersion() const;
|
||||||
std::size_t GetContentCount() const;
|
std::size_t GetContentCount() const;
|
||||||
u32 GetBootContentID() const;
|
u32 GetBootContentID() const;
|
||||||
|
|||||||
+13
-12
@@ -601,13 +601,13 @@ static std::string GetTitleFileName(NCCHContainer& ncch) {
|
|||||||
if (!ncch.LoadSectionExeFS("icon", smdh_buffer) || smdh_buffer.size() != sizeof(SMDH)) {
|
if (!ncch.LoadSectionExeFS("icon", smdh_buffer) || smdh_buffer.size() != sizeof(SMDH)) {
|
||||||
LOG_WARNING(Core, "Failed to load icon in ExeFS or size incorrect");
|
LOG_WARNING(Core, "Failed to load icon in ExeFS or size incorrect");
|
||||||
return NormalizeFilename(
|
return NormalizeFilename(
|
||||||
fmt::format("{:016x} {} ({})", program_id, codeset_name, product_code));
|
fmt::format("{:016X} {} ({})", program_id, codeset_name, product_code));
|
||||||
} else {
|
} else {
|
||||||
SMDH smdh;
|
SMDH smdh;
|
||||||
std::memcpy(&smdh, smdh_buffer.data(), smdh_buffer.size());
|
std::memcpy(&smdh, smdh_buffer.data(), smdh_buffer.size());
|
||||||
const auto short_title =
|
const auto short_title =
|
||||||
Common::UTF16BufferToUTF8(smdh.GetShortTitle(SMDH::TitleLanguage::English));
|
Common::UTF16BufferToUTF8(smdh.GetShortTitle(SMDH::TitleLanguage::English));
|
||||||
return NormalizeFilename(fmt::format("{:016x} {} ({}) ({})", program_id, short_title,
|
return NormalizeFilename(fmt::format("{:016X} {} ({}) ({})", program_id, short_title,
|
||||||
product_code, smdh.GetRegionString()));
|
product_code, smdh.GetRegionString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -699,10 +699,10 @@ bool SDMCImporter::BuildCIA(CIABuildType build_type, const ContentSpecifier& spe
|
|||||||
: fmt::format("{}title/{:08x}/{:08x}/content/", config.sdmc_path,
|
: fmt::format("{}title/{:08x}/{:08x}/content/", config.sdmc_path,
|
||||||
(specifier.id >> 32), (specifier.id & 0xFFFFFFFF));
|
(specifier.id >> 32), (specifier.id & 0xFFFFFFFF));
|
||||||
|
|
||||||
static constexpr std::array<std::string_view, 3> BuildTypeSuffixes{{
|
static constexpr std::array<std::string_view, 3> BuildTypeExts{{
|
||||||
".standard.cia",
|
"standard.cia",
|
||||||
".pirate-legit.cia",
|
"piratelegit.cia",
|
||||||
".legit.cia",
|
"legit.cia",
|
||||||
}};
|
}};
|
||||||
if (auto_filename) {
|
if (auto_filename) {
|
||||||
if (destination.back() != '/' && destination.back() != '\\') {
|
if (destination.back() != '/' && destination.back() != '\\') {
|
||||||
@@ -710,16 +710,17 @@ bool SDMCImporter::BuildCIA(CIABuildType build_type, const ContentSpecifier& spe
|
|||||||
}
|
}
|
||||||
const auto boot_content_path =
|
const auto boot_content_path =
|
||||||
fmt::format("{}{:08x}.app", physical_path, tmd.GetBootContentID());
|
fmt::format("{}{:08x}.app", physical_path, tmd.GetBootContentID());
|
||||||
|
NCCHContainer ncch;
|
||||||
if (is_nand) {
|
if (is_nand) {
|
||||||
NCCHContainer ncch(std::make_shared<FileUtil::IOFile>(boot_content_path, "rb"));
|
ncch.OpenFile(std::make_shared<FileUtil::IOFile>(boot_content_path, "rb"));
|
||||||
destination.append(GetTitleFileName(ncch))
|
|
||||||
.append(BuildTypeSuffixes.at(static_cast<std::size_t>(build_type)));
|
|
||||||
} else {
|
} else {
|
||||||
const auto relative_path = boot_content_path.substr(config.sdmc_path.size() - 1);
|
const auto relative_path = boot_content_path.substr(config.sdmc_path.size() - 1);
|
||||||
NCCHContainer ncch(std::make_shared<SDMCFile>(config.sdmc_path, relative_path, "rb"));
|
ncch.OpenFile(std::make_shared<SDMCFile>(config.sdmc_path, relative_path, "rb"));
|
||||||
destination.append(GetTitleFileName(ncch))
|
|
||||||
.append(BuildTypeSuffixes.at(static_cast<std::size_t>(build_type)));
|
|
||||||
}
|
}
|
||||||
|
const auto filename =
|
||||||
|
fmt::format("{} (v{}).{}", GetTitleFileName(ncch), tmd.GetTitleVersionString(),
|
||||||
|
BuildTypeExts.at(static_cast<std::size_t>(build_type)));
|
||||||
|
destination.append(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = cia_builder->Init(build_type, destination, tmd, specifier.maximum_size, callback);
|
bool ret = cia_builder->Init(build_type, destination, tmd, specifier.maximum_size, callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user