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

Function ConChangeDirectory

src/console_cmds.cpp:615–642  ·  view source on GitHub ↗

Change the dir via console */

Source from the content-addressed store, hash-verified

613
614/* Change the dir via console */
615static bool ConChangeDirectory(std::span<std::string_view> argv)
616{
617 if (argv.empty()) {
618 IConsolePrint(CC_HELP, "Change the dir via console. Usage: 'cd <directory | number>'.");
619 return true;
620 }
621
622 if (argv.size() != 2) return false;
623
624 std::string_view file = argv[1];
625 _console_file_list_savegame.ValidateFileList(true);
626 const FiosItem *item = _console_file_list_savegame.FindItem(file);
627 if (item != nullptr) {
628 switch (item->type.detailed) {
629 case DFT_FIOS_DIR:
630 case DFT_FIOS_DRIVE:
631 case DFT_FIOS_PARENT:
632 FiosBrowseTo(item);
633 break;
634 default: IConsolePrint(CC_ERROR, "{}: Not a directory.", file);
635 }
636 } else {
637 IConsolePrint(CC_ERROR, "{}: No such file or directory.", file);
638 }
639
640 _console_file_list_savegame.InvalidateFileList();
641 return true;
642}
643
644static bool ConPrintWorkingDirectory(std::span<std::string_view> argv)
645{

Callers

nothing calls this directly

Calls 7

FiosBrowseToFunction · 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