UICommon/GameFile: File name column will show the directory name for extracted games
This commit is contained in:
parent
059282df6f
commit
7e21b630fe
|
@ -103,8 +103,6 @@ GameFile::GameFile() = default;
|
|||
|
||||
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));
|
||||
if (volume != nullptr)
|
||||
|
@ -157,6 +155,13 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
|||
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")
|
||||
{
|
||||
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
|
||||
|
@ -350,6 +355,17 @@ bool GameFile::IsElfOrDol() const
|
|||
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)
|
||||
{
|
||||
std::string data;
|
||||
|
|
|
@ -131,6 +131,7 @@ private:
|
|||
const std::map<DiscIO::Language, std::string>& strings);
|
||||
const std::string&
|
||||
LookupUsingConfigLanguage(const std::map<DiscIO::Language, std::string>& strings) const;
|
||||
std::string FindFolderName() const;
|
||||
std::string GetExtension() const;
|
||||
bool IsElfOrDol() const;
|
||||
bool ReadXMLMetadata(const std::string& path);
|
||||
|
|
Loading…
Reference in New Issue