MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FioFindFullPath

Function FioFindFullPath

src/fileio.cpp:144–161  ·  view source on GitHub ↗

* Find a path to the filename in one of the search directories. * @param subdir Subdirectory to try. * @param filename Filename to look for. * @return String containing the path if the path was found, else an empty string. */

Source from the content-addressed store, hash-verified

142 * @return String containing the path if the path was found, else an empty string.
143 */
144std::string FioFindFullPath(Subdirectory subdir, std::string_view filename)
145{
146 assert(subdir < NUM_SUBDIRS);
147
148 for (Searchpath sp : _valid_searchpaths) {
149 std::string buf = FioGetDirectory(sp, subdir);
150 buf += filename;
151 if (FileExists(buf)) return buf;
152#if !defined(_WIN32)
153 /* Be, as opening files, aware that sometimes the filename
154 * might be in uppercase when it is in lowercase on the
155 * disk. Of course Windows doesn't care about casing. */
156 if (strtolower(buf, _searchpaths[sp].size() - 1) && FileExists(buf)) return buf;
157#endif
158 }
159
160 return {};
161}
162
163std::string FioGetDirectory(Searchpath sp, Subdirectory subdir)
164{

Callers 9

SelectDriverImplMethod · 0.85
DeterminePathsFunction · 0.85
LoadFontMethod · 0.85
TryLoadFontFromFileMethod · 0.85
LoadFontFromFileMethod · 0.85
GetSMFFileMethod · 0.85
CreateMainWindowMethod · 0.85

Calls 4

FioGetDirectoryFunction · 0.85
FileExistsFunction · 0.85
strtolowerFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected