(svn r2941) -Feature: Implement the console command rm to remove savegames
authortron
Sun, 11 Sep 2005 14:57:56 +0000
changeset 2415 3093e6277340
parent 2414 cc0904ef2d0d
child 2416 ba01d6a50765
(svn r2941) -Feature: Implement the console command rm to remove savegames
console_cmds.c
--- a/console_cmds.c	Sun Sep 11 14:20:46 2005 +0000
+++ b/console_cmds.c	Sun Sep 11 14:57:56 2005 +0000
@@ -247,6 +247,32 @@
 	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 @@
 	IConsoleCmdRegister("scrollto",     ConScrollToTile);
 	IConsoleCmdRegister("alias",        ConAlias);
 	IConsoleCmdRegister("load",         ConLoad);
+	IConsoleCmdRegister("rm",           ConRemove);
 	IConsoleCmdRegister("save",         ConSave);
 	IConsoleCmdRegister("ls",           ConListFiles);
 	IConsoleCmdRegister("cd",           ConChangeDirectory);