From a59edfe8cf4c3dd9275058ca1acd88019a3f6abf Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 20 Jun 2017 21:51:40 +0200 Subject: FilesystemPanel: Put partitions in separate folders when extracting all partitions --- Source/Core/DiscIO/DiscExtractor.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Source/Core/DiscIO/DiscExtractor.cpp') diff --git a/Source/Core/DiscIO/DiscExtractor.cpp b/Source/Core/DiscIO/DiscExtractor.cpp index f5dd28d9a5..b56f120a67 100644 --- a/Source/Core/DiscIO/DiscExtractor.cpp +++ b/Source/Core/DiscIO/DiscExtractor.cpp @@ -6,15 +6,42 @@ #include #include +#include #include #include "Common/CommonTypes.h" +#include "Common/StringUtil.h" #include "DiscIO/Enums.h" #include "DiscIO/Filesystem.h" #include "DiscIO/Volume.h" namespace DiscIO { +std::string DirectoryNameForPartitionType(u32 partition_type) +{ + switch (partition_type) + { + case 0: + return "DATA"; + case 1: + return "UPDATE"; + case 2: + return "CHANNEL"; + default: + const std::string type_as_game_id{static_cast((partition_type >> 24) & 0xFF), + static_cast((partition_type >> 16) & 0xFF), + static_cast((partition_type >> 8) & 0xFF), + static_cast(partition_type & 0xFF)}; + if (std::all_of(type_as_game_id.cbegin(), type_as_game_id.cend(), + [](char c) { return std::isprint(c, std::locale::classic()); })) + { + return "P-" + type_as_game_id; + } + + return StringFromFormat("P%u", partition_type); + } +} + u64 ReadFile(const Volume& volume, const Partition& partition, const FileInfo* file_info, u8* buffer, u64 max_buffer_size, u64 offset_in_file) { -- cgit v1.2.3