mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-07-11 09:44:17 +02:00
FileSystem: Add a case-insensitive match for nvm and mec file loading.
This commit is contained in:
@@ -994,6 +994,37 @@ std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode, Error*
|
||||
#endif
|
||||
}
|
||||
|
||||
std::FILE* FileSystem::OpenCFileTryIgnoreCase(const char* filename, const char* mode, Error* error)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
return OpenCFile(filename, mode, error);
|
||||
#else
|
||||
std::FILE* fp = std::fopen(filename, mode);
|
||||
const auto cur_errno = errno;
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
const auto dir = std::string(Path::GetDirectory(filename));
|
||||
FindResultsArray files;
|
||||
if (FindFiles(dir.c_str(), "*", FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES, &files))
|
||||
{
|
||||
for (auto& file : files)
|
||||
{
|
||||
if (StringUtil::compareNoCase(file.FileName, filename))
|
||||
{
|
||||
fp = std::fopen(file.FileName.c_str(), mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fp)
|
||||
Error::SetErrno(error, cur_errno);
|
||||
return fp;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int FileSystem::OpenFDFile(const char* filename, int flags, int mode, Error* error)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -1015,6 +1046,11 @@ FileSystem::ManagedCFilePtr FileSystem::OpenManagedCFile(const char* filename, c
|
||||
return ManagedCFilePtr(OpenCFile(filename, mode, error));
|
||||
}
|
||||
|
||||
FileSystem::ManagedCFilePtr FileSystem::OpenManagedCFileTryIgnoreCase(const char* filename, const char* mode, Error* error)
|
||||
{
|
||||
return ManagedCFilePtr(OpenCFileTryIgnoreCase(filename, mode, error));
|
||||
}
|
||||
|
||||
std::FILE* FileSystem::OpenSharedCFile(const char* filename, const char* mode, FileShareMode share_mode, Error* error)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
Reference in New Issue
Block a user