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

Function ConRemove

src/console_cmds.cpp:537–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535}
536
537static bool ConRemove(std::span<std::string_view> argv)
538{
539 if (argv.empty()) {
540 IConsolePrint(CC_HELP, "Remove a savegame by name or index. Usage: 'rm <file | number>'.");
541 return true;
542 }
543
544 if (argv.size() != 2) return false;
545
546 std::string_view file = argv[1];
547 _console_file_list_savegame.ValidateFileList();
548 const FiosItem *item = _console_file_list_savegame.FindItem(file);
549 if (item != nullptr) {
550 if (item->type.abstract == FT_SAVEGAME) {
551 if (!FioRemove(item->name)) {
552 IConsolePrint(CC_ERROR, "Failed to delete '{}'.", item->name);
553 }
554 } else {
555 IConsolePrint(CC_ERROR, "'{}' is not a savegame.", file);
556 }
557 } else {
558 IConsolePrint(CC_ERROR, "'{}' could not be found.", file);
559 }
560
561 _console_file_list_savegame.InvalidateFileList();
562 return true;
563}
564
565
566/* List all the files in the current dir via console */

Callers

nothing calls this directly

Calls 7

FioRemoveFunction · 0.85
ValidateFileListMethod · 0.80
FindItemMethod · 0.80
InvalidateFileListMethod · 0.80
IConsolePrintFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected