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

Function GetFileTitle

src/fios.cpp:370–381  ·  view source on GitHub ↗

* Get the title of a file, which (if exists) is stored in a file named * the same as the data file but with '.title' added to it. * @param file filename to get the title for * @param subdir the sub directory to search in * @return The file title. */

Source from the content-addressed store, hash-verified

368 * @return The file title.
369 */
370static std::string GetFileTitle(std::string_view file, Subdirectory subdir)
371{
372 std::string filename = fmt::format("{}.title", file);
373 auto f = FioFOpenFile(filename, "r", subdir);
374 if (!f.has_value()) return {};
375
376 char title[80];
377 size_t read = fread(title, 1, lengthof(title), *f);
378
379 assert(read <= lengthof(title));
380 return StrMakeValid(std::string_view{title, read});
381}
382
383/**
384 * Callback for FiosGetFileList. It tells if a file is a savegame or not.

Callers 4

Calls 3

FioFOpenFileFunction · 0.85
StrMakeValidFunction · 0.70
formatFunction · 0.50

Tested by

no test coverage detected