From a8cacc5c633465b436525ce8a9037e0f6e2635ac Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 17 Dec 2002 18:31:08 +0000 Subject: [PATCH] added delete removed a strange include Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@581 --- src/shell/shell.cpp | 6 ++++-- src/shell/shell_batch.cpp | 1 - src/shell/shell_cmds.cpp | 21 +++++++++++++++++++-- src/shell/shell_inc.h | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 8b405f23..3c6e9e5a 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -186,7 +186,8 @@ void SHELL_Init() { MSG_Add("SHELL_ILLEGAL_SWITCH","Illegal switch: %s\n"); MSG_Add("SHELL_CMD_CHDIR_ERROR","Unable to change to: %s\n"); MSG_Add("SHELL_CMD_MKDIR_ERROR","Unable to make: %s\n"); - MSG_Add("SHELL_CMD_RMDIR_ERROR","Unable to remove: %\n"); + MSG_Add("SHELL_CMD_RMDIR_ERROR","Unable to remove: %s\n"); + MSG_Add("SHELL_CMD_DEL_ERROR","Unable to delete: %s\n"); MSG_Add("SHELL_SYNTAXERROR","The syntax of the command is incorrect.\n"); MSG_Add("SHELL_CMD_SET_NOT_SET","Environment variable %s not defined\n"); MSG_Add("SHELL_CMD_SET_OUT_OF_SPACE","Not enough environment space left.\n"); @@ -217,8 +218,9 @@ void SHELL_Init() { MSG_Add("SHELL_CMD_GOTO_HELP","Jump to a labeled line in a batch script.\n"); MSG_Add("SHELL_CMD_TYPE_HELP","Display the contents of a text-file.\n"); MSG_Add("SHELL_CMD_REM_HELP","Add comments in a batch file.\n"); - MSG_Add("SHELL_CMD_RENAME_WILD","This is a simple Rename, no wildcards allowed!\n"); + MSG_Add("SHELL_CMD_NO_WILD","This is a simple version of the command, no wildcards allowed!\n"); MSG_Add("SHELL_CMD_RENAME_HELP","Renames files.\n"); + MSG_Add("SHELL_CMD_DELETE_HELP","Removes files.\n"); /* Regular startup */ call_shellstop=CALLBACK_Allocate(); /* Setup the startup CS:IP to kill the last running machine when exitted */ diff --git a/src/shell/shell_batch.cpp b/src/shell/shell_batch.cpp index 769dccea..304f5987 100644 --- a/src/shell/shell_batch.cpp +++ b/src/shell/shell_batch.cpp @@ -20,7 +20,6 @@ #include #include "shell_inc.h" -#include "cpu.h" BatchFile::BatchFile(DOS_Shell * host,char * name, char * cmd_line) { diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 24934ece..9a05d530 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -28,6 +28,8 @@ static SHELL_Cmd cmd_list[]={ "CLS", 0, &DOS_Shell::CMD_CLS, "SHELL_CMD_CLS_HELP", // "COPY", 0, &DOS_Shell::CMD_COPY, "Copy Files.", "DIR", 0, &DOS_Shell::CMD_DIR, "SHELL_CMD_DIR_HELP", + "DEL", 1, &DOS_Shell::CMD_DELETE, "SHELL_CMD_DELETE_HELP", + "DELETE", 0, &DOS_Shell::CMD_DELETE, "SHELL_CMD_DELETE_HELP", "ECHO", 0, &DOS_Shell::CMD_ECHO, "SHELL_CMD_ECHO_HELP", "EXIT", 0, &DOS_Shell::CMD_EXIT, "SHELL_CMD_EXIT_HELP", "HELP", 0, &DOS_Shell::CMD_HELP, "SHELL_CMD_HELP_HELP", @@ -39,7 +41,7 @@ static SHELL_Cmd cmd_list[]={ "TYPE", 0, &DOS_Shell::CMD_TYPE, "SHELL_CMD_TYPE_HELP", "REM", 0, &DOS_Shell::CMD_REM, "SHELL_CMD_REM_HELP", "RENAME", 0, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP", - "REN", 0, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP", + "REN", 1, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP", /* "CHDIR", 0, &DOS_Shell::CMD_CHDIR, "Change Directory", "MKDIR", 0, &DOS_Shell::CMD_MKDIR, "Make Directory", @@ -57,6 +59,7 @@ void DOS_Shell::DoCommand(char * line) { if (*line==32) break; if (*line=='/') break; if ((*line=='.') && (*(line+1)=='.')) break; +// if ((*line=='.') && (*(line+1)==0)) break; *cmd_write++=*line++; } *cmd_write=0; @@ -81,6 +84,20 @@ void DOS_Shell::CMD_CLS(char * args) { CALLBACK_RunRealInt(0x10); }; +void DOS_Shell::CMD_DELETE(char * args) { + char * rem=ScanCMDRemain(args); + if (rem) { + WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem); + return; + } + if((strchr(args,'*')!=NULL) || (strchr(args,'?')!=NULL) ) { WriteOut(MSG_Get("SHELL_CMD_NO_WILD"));return;} + + if (!DOS_UnlinkFile(args)) { + WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),args); + } + +}; + void DOS_Shell::CMD_HELP(char * args){ /* Print the help */ WriteOut(MSG_Get("SHELL_CMD_HELP")); @@ -94,7 +111,7 @@ void DOS_Shell::CMD_HELP(char * args){ void DOS_Shell::CMD_RENAME(char * args){ if(!*args) {SyntaxError();return;} - if((strchr(args,'*')!=NULL) || (strchr(args,'?')!=NULL) ) { WriteOut(MSG_Get("SHELL_CMD_RENAME_WILD"));} + if((strchr(args,'*')!=NULL) || (strchr(args,'?')!=NULL) ) { WriteOut(MSG_Get("SHELL_CMD_NO_WILD"));return;} char * arg2 =StripWord(args); DOS_Rename(args,arg2); } diff --git a/src/shell/shell_inc.h b/src/shell/shell_inc.h index fefd0d0b..e21f323d 100644 --- a/src/shell/shell_inc.h +++ b/src/shell/shell_inc.h @@ -66,6 +66,7 @@ public: void CMD_CLS(char * args); void CMD_COPY(char * args); void CMD_DIR(char * args); + void CMD_DELETE(char * args); void CMD_ECHO(char * args); void CMD_EXIT(char * args); void CMD_MKDIR(char * args);