mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Convert VolumeDirectory names back to SHIFT-JIS (issue #9988)
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
@ -26,6 +27,7 @@ namespace DiscIO
|
||||
{
|
||||
static u32 ComputeNameSize(const File::FSTEntry& parent_entry);
|
||||
static std::string ASCIIToUppercase(std::string str);
|
||||
static void ConvertUTF8NamesToSHIFTJIS(File::FSTEntry& parent_entry);
|
||||
|
||||
const size_t CVolumeDirectory::MAX_NAME_LENGTH;
|
||||
const size_t CVolumeDirectory::MAX_ID_LENGTH;
|
||||
@ -350,6 +352,9 @@ void CVolumeDirectory::BuildFST()
|
||||
m_fst_data.clear();
|
||||
|
||||
File::FSTEntry rootEntry = File::ScanDirectoryTree(m_root_directory, true);
|
||||
|
||||
ConvertUTF8NamesToSHIFTJIS(rootEntry);
|
||||
|
||||
u32 name_table_size = Common::AlignUp(ComputeNameSize(rootEntry), 1ull << m_address_shift);
|
||||
u64 total_entries = rootEntry.size + 1; // The root entry itself isn't counted in rootEntry.size
|
||||
|
||||
@ -501,6 +506,17 @@ static u32 ComputeNameSize(const File::FSTEntry& parent_entry)
|
||||
return name_size;
|
||||
}
|
||||
|
||||
static void ConvertUTF8NamesToSHIFTJIS(File::FSTEntry& parent_entry)
|
||||
{
|
||||
for (File::FSTEntry& entry : parent_entry.children)
|
||||
{
|
||||
if (entry.isDirectory)
|
||||
ConvertUTF8NamesToSHIFTJIS(entry);
|
||||
|
||||
entry.virtualName = UTF8ToSHIFTJIS(entry.virtualName);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string ASCIIToUppercase(std::string str)
|
||||
{
|
||||
std::transform(str.begin(), str.end(), str.begin(),
|
||||
|
Reference in New Issue
Block a user