* 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. */
| 368 | * @return The file title. |
| 369 | */ |
| 370 | static 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. |
no test coverage detected