GameList: Always open icon cache with r+b on Linux

Fixes flock() error on startup.
This commit is contained in:
Stenzek 2024-07-13 18:23:53 +10:00
parent 2cfa535784
commit 5da6c926d9
No known key found for this signature in database

View file

@ -1655,9 +1655,15 @@ static constexpr const char MEMCARD_TIMESTAMP_CACHE_SIGNATURE[] = {'M', 'C', 'D'
FileSystem::ManagedCFilePtr GameList::OpenMemoryCardTimestampCache(bool for_write) FileSystem::ManagedCFilePtr GameList::OpenMemoryCardTimestampCache(bool for_write)
{ {
const std::string filename = Path::Combine(EmuFolders::Cache, "memcard_icons.cache"); const std::string filename = Path::Combine(EmuFolders::Cache, "memcard_icons.cache");
const char* mode = for_write ? "r+b" : "rb";
const FileSystem::FileShareMode share_mode = const FileSystem::FileShareMode share_mode =
for_write ? FileSystem::FileShareMode::DenyReadWrite : FileSystem::FileShareMode::DenyWrite; for_write ? FileSystem::FileShareMode::DenyReadWrite : FileSystem::FileShareMode::DenyWrite;
#ifdef _WIN32
const char* mode = for_write ? "r+b" : "rb";
#else
// Always open read/write on Linux, since we need it for flock().
const char* mode = "r+b";
#endif
FileSystem::ManagedCFilePtr fp = FileSystem::OpenManagedSharedCFile(filename.c_str(), mode, share_mode, nullptr); FileSystem::ManagedCFilePtr fp = FileSystem::OpenManagedSharedCFile(filename.c_str(), mode, share_mode, nullptr);
if (fp) if (fp)
return fp; return fp;