Merge b9d2a433bf
into 4d0cf1315e
This commit is contained in:
commit
a5d4de193b
|
@ -103,8 +103,6 @@ GameFile::GameFile() = default;
|
||||||
|
|
||||||
GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
||||||
{
|
{
|
||||||
m_file_name = PathToFileName(m_file_path);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolume(m_file_path));
|
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolume(m_file_path));
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
|
@ -157,6 +155,13 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
||||||
m_blob_type = DiscIO::BlobType::DIRECTORY;
|
m_blob_type = DiscIO::BlobType::DIRECTORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the game is extracted then use the folder name two/three directories up instead
|
||||||
|
if (m_blob_type == DiscIO::BlobType::DIRECTORY)
|
||||||
|
m_file_name = FindFolderName();
|
||||||
|
|
||||||
|
if (m_file_name.empty())
|
||||||
|
m_file_name = PathToFileName(m_file_path);
|
||||||
|
|
||||||
if (!IsValid() && GetExtension() == ".json")
|
if (!IsValid() && GetExtension() == ".json")
|
||||||
{
|
{
|
||||||
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
|
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
|
||||||
|
@ -350,6 +355,17 @@ bool GameFile::IsElfOrDol() const
|
||||||
return extension == ".elf" || extension == ".dol";
|
return extension == ".elf" || extension == ".dol";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function for finding the folder name two (three if a Wii game) directories up for use in the file
|
||||||
|
// name column for extracted games Returns a blank string if the folder can't be found
|
||||||
|
std::string GameFile::FindFolderName() const
|
||||||
|
{
|
||||||
|
const std::filesystem::path game_file_path = StringToPath(m_file_path).parent_path().parent_path();
|
||||||
|
return PathToString(m_platform == DiscIO::Platform::WiiDisc &&
|
||||||
|
PathToString(game_file_path.filename()) == "DATA" ?
|
||||||
|
game_file_path.parent_path() :
|
||||||
|
game_file_path.filename());
|
||||||
|
}
|
||||||
|
|
||||||
bool GameFile::ReadXMLMetadata(const std::string& path)
|
bool GameFile::ReadXMLMetadata(const std::string& path)
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
|
|
|
@ -131,6 +131,7 @@ private:
|
||||||
const std::map<DiscIO::Language, std::string>& strings);
|
const std::map<DiscIO::Language, std::string>& strings);
|
||||||
const std::string&
|
const std::string&
|
||||||
LookupUsingConfigLanguage(const std::map<DiscIO::Language, std::string>& strings) const;
|
LookupUsingConfigLanguage(const std::map<DiscIO::Language, std::string>& strings) const;
|
||||||
|
std::string FindFolderName() const;
|
||||||
std::string GetExtension() const;
|
std::string GetExtension() const;
|
||||||
bool IsElfOrDol() const;
|
bool IsElfOrDol() const;
|
||||||
bool ReadXMLMetadata(const std::string& path);
|
bool ReadXMLMetadata(const std::string& path);
|
||||||
|
|
Loading…
Reference in New Issue