summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-09-11 14:57:56 +0000
committertron <tron@openttd.org>2005-09-11 14:57:56 +0000
commite78d41bbb26affa6459dd4919a6366c95a6f62a4 (patch)
tree66848adeee34507aabf274cd8e0b59fb83bb640d
parentffd044c5e8c890f910163cc211ff2e330c88d717 (diff)
downloadopenttd-e78d41bbb26affa6459dd4919a6366c95a6f62a4.tar.xz
(svn r2941) -Feature: Implement the console command rm to remove savegames
-rw-r--r--console_cmds.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 5eeb261ed..165fd7ce4 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -247,6 +247,32 @@ DEF_CONSOLE_CMD(ConLoad)
return true;
}
+
+DEF_CONSOLE_CMD(ConRemove)
+{
+ const FiosItem* item;
+ const char* file;
+
+ if (argc == 0) {
+ IConsoleHelp("Remove a savegame by name or index. Usage: 'rm <file | number>'");
+ return true;
+ }
+
+ if (argc != 2) return false;
+
+ file = argv[1];
+ item = GetFiosItem(file);
+ if (item != NULL) {
+ if (!FiosDelete(item->name))
+ IConsolePrintF(_icolour_err, "%s: Failed to delete file", file);
+ } else
+ IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
+
+ FiosFreeSavegameList();
+ return true;
+}
+
+
/* List all the files in the current dir via console */
DEF_CONSOLE_CMD(ConListFiles)
{
@@ -1260,6 +1286,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("scrollto", ConScrollToTile);
IConsoleCmdRegister("alias", ConAlias);
IConsoleCmdRegister("load", ConLoad);
+ IConsoleCmdRegister("rm", ConRemove);
IConsoleCmdRegister("save", ConSave);
IConsoleCmdRegister("ls", ConListFiles);
IConsoleCmdRegister("cd", ConChangeDirectory);