MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / OpenCFileTryIgnoreCase

Method OpenCFileTryIgnoreCase

common/FileSystem.cpp:1009–1037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1007}
1008
1009std::FILE* FileSystem::OpenCFileTryIgnoreCase(const char* filename, const char* mode, Error* error)
1010{
1011#if defined(_WIN32) || defined(__APPLE__)
1012 return OpenCFile(filename, mode, error);
1013#else
1014 std::FILE* fp = std::fopen(filename, mode);
1015 const auto cur_errno = errno;
1016
1017 if (!fp)
1018 {
1019 const auto dir = std::string(Path::GetDirectory(filename));
1020 FindResultsArray files;
1021 if (FindFiles(dir.c_str(), "*", FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES, &files))
1022 {
1023 for (auto& file : files)
1024 {
1025 if (StringUtil::compareNoCase(file.FileName, filename))
1026 {
1027 fp = std::fopen(file.FileName.c_str(), mode);
1028 break;
1029 }
1030 }
1031 }
1032 }
1033 if (!fp)
1034 Error::SetErrno(error, cur_errno);
1035 return fp;
1036#endif
1037}
1038
1039
1040int FileSystem::OpenFDFile(const char* filename, int flags, int mode, Error* error)

Callers

nothing calls this directly

Calls 3

compareNoCaseFunction · 0.85
stringClass · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected