mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-23 05:49:43 +00:00
GameList: Avoid double fopen/read of EXEs
Some checks failed
Create rolling release / Windows x64 Build (push) Has been cancelled
Create rolling release / Windows x64 SSE2 Build (push) Has been cancelled
Create rolling release / Windows ARM64 Build (push) Has been cancelled
Create rolling release / Linux x64 AppImage (push) Has been cancelled
Create rolling release / Linux x64 SSE2 AppImage (push) Has been cancelled
Create rolling release / MacOS Universal Build (push) Has been cancelled
Create rolling release / Create Release (push) Has been cancelled
Some checks failed
Create rolling release / Windows x64 Build (push) Has been cancelled
Create rolling release / Windows x64 SSE2 Build (push) Has been cancelled
Create rolling release / Windows ARM64 Build (push) Has been cancelled
Create rolling release / Linux x64 AppImage (push) Has been cancelled
Create rolling release / Linux x64 SSE2 AppImage (push) Has been cancelled
Create rolling release / MacOS Universal Build (push) Has been cancelled
Create rolling release / Create Release (push) Has been cancelled
This commit is contained in:
parent
2d04f2eff9
commit
7d2216c289
@ -1187,8 +1187,11 @@ bool Bus::SideloadEXE(const std::string& path, Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stupid Android...
|
||||
std::string filename = FileSystem::GetDisplayNameFromPath(path);
|
||||
|
||||
bool okay = true;
|
||||
if (StringUtil::EndsWithNoCase(path, ".cpe"))
|
||||
if (StringUtil::EndsWithNoCase(filename, ".cpe"))
|
||||
{
|
||||
okay = InjectCPE(exe_data->cspan(), true, error);
|
||||
}
|
||||
|
@ -179,10 +179,13 @@ bool GameList::GetExeListEntry(const std::string& path, GameList::Entry* entry)
|
||||
if (entry->file_size < 0)
|
||||
return false;
|
||||
|
||||
entry->title = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(path));
|
||||
// Stupid Android...
|
||||
const std::string filename = FileSystem::GetDisplayNameFromPath(path);
|
||||
|
||||
entry->title = Path::GetFileTitle(filename);
|
||||
entry->type = EntryType::PSExe;
|
||||
|
||||
if (StringUtil::EndsWithNoCase(path, ".cpe"))
|
||||
if (StringUtil::EndsWithNoCase(filename, ".cpe"))
|
||||
{
|
||||
u32 magic;
|
||||
if (std::fread(&magic, sizeof(magic), 1, fp.get()) != 1 || magic != BIOS::CPE_MAGIC)
|
||||
@ -207,7 +210,14 @@ bool GameList::GetExeListEntry(const std::string& path, GameList::Entry* entry)
|
||||
entry->region = BIOS::GetPSExeDiscRegion(header);
|
||||
}
|
||||
|
||||
const GameHash hash = System::GetGameHashFromFile(path.c_str());
|
||||
const auto data = FileSystem::ReadBinaryFile(fp.get());
|
||||
if (!data.has_value())
|
||||
{
|
||||
WARNING_LOG("Failed to read {}", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
const GameHash hash = System::GetGameHashFromBuffer(filename, data->cspan());
|
||||
entry->serial = hash ? System::GetGameHashId(hash) : std::string();
|
||||
return true;
|
||||
}
|
||||
|
@ -997,8 +997,12 @@ GameHash System::GetGameHashFromFile(const char* path)
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
const std::string display_name = FileSystem::GetDisplayNameFromPath(path);
|
||||
return GetGameHashFromBuffer(display_name, data->cspan(), IsoReader::ISOPrimaryVolumeDescriptor{}, 0);
|
||||
return GetGameHashFromBuffer(FileSystem::GetDisplayNameFromPath(path), data->cspan());
|
||||
}
|
||||
|
||||
GameHash System::GetGameHashFromBuffer(const std::string_view filename, const std::span<const u8> data)
|
||||
{
|
||||
return GetGameHashFromBuffer(filename, data, IsoReader::ISOPrimaryVolumeDescriptor{}, 0);
|
||||
}
|
||||
|
||||
std::string System::GetExecutableNameForImage(IsoReader& iso, bool strip_subdirectories)
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
class ByteStream;
|
||||
@ -143,6 +144,7 @@ bool ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, std
|
||||
std::string GetGameHashId(GameHash hash);
|
||||
bool GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash* out_hash);
|
||||
GameHash GetGameHashFromFile(const char* path);
|
||||
GameHash GetGameHashFromBuffer(const std::string_view filename, const std::span<const u8> data);
|
||||
DiscRegion GetRegionForSerial(const std::string_view serial);
|
||||
DiscRegion GetRegionFromSystemArea(CDImage* cdi);
|
||||
DiscRegion GetRegionForImage(CDImage* cdi);
|
||||
|
Loading…
Reference in New Issue
Block a user