If we're gonna support delete why not add some wildcard support too.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@583
This commit is contained in:
parent
4ff5924eb1
commit
8a7b36aaee
2 changed files with 21 additions and 8 deletions
|
@ -180,6 +180,7 @@ static char * init_line="/INIT AUTOEXEC.BAT";
|
|||
|
||||
void SHELL_Init() {
|
||||
/* Add messages */
|
||||
MSG_Add("SHELL_ILLEGAL_PATH","Illegal Path\n");
|
||||
MSG_Add("SHELL_CMD_HELP","supported commands are:\n");
|
||||
MSG_Add("SHELL_CMD_ECHO_ON","ECHO is on\n");
|
||||
MSG_Add("SHELL_CMD_ECHO_OFF","ECHO is off\n");
|
||||
|
@ -199,7 +200,6 @@ void SHELL_Init() {
|
|||
MSG_Add("SHELL_CMD_FILE_NOT_FOUND","File %s not found.\n");
|
||||
MSG_Add("SHELL_CMD_FILE_EXISTS","File %s already exists.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_INTRO","Directory of %s.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_PATH_ERROR","Illegal Path\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_USED","%5d File(s) %17s Bytes\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_FREE","%5d Dir(s) %17s Bytes free\n");
|
||||
MSG_Add("SHELL_EXECUTE_DRIVE_NOT_FOUND","Drive %c does not exist!\n");
|
||||
|
|
|
@ -90,13 +90,26 @@ void DOS_Shell::CMD_DELETE(char * args) {
|
|||
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);
|
||||
char full[DOS_PATHLENGTH];
|
||||
if (!DOS_Canonicalize(args,full)) { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));return; }
|
||||
//TODO Maybe support confirmation for *.* like dos does.
|
||||
bool res=DOS_FindFirst(args,0xff);
|
||||
if (!res) {
|
||||
WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),args);return;
|
||||
}
|
||||
|
||||
};
|
||||
//end can't be 0, but if it is we'll get a nice crash, who cares :)
|
||||
char * end=strrchr(full,'\\')+1;*end=0;
|
||||
char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u time,date;Bit8u attr;
|
||||
DOS_DTA dta(dos.dta);
|
||||
while (res) {
|
||||
dta.GetResult(name,size,date,time,attr);
|
||||
if (!(attr & (DOS_ATTR_DIRECTORY|DOS_ATTR_READ_ONLY))) {
|
||||
strcpy(end,name);
|
||||
if (!DOS_UnlinkFile(full)) WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),full);
|
||||
}
|
||||
res=DOS_FindNext();
|
||||
}
|
||||
}
|
||||
|
||||
void DOS_Shell::CMD_HELP(char * args){
|
||||
/* Print the help */
|
||||
|
@ -216,7 +229,7 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
|
||||
/* Make a full path in the args */
|
||||
if (!DOS_Canonicalize(args,path)) {
|
||||
WriteOut(MSG_Get("SHELL_CMD_DIR_PATH_ERROR"));
|
||||
WriteOut(MSG_Get("SHELL_CMD_ILLEGAL_PATH"));
|
||||
return;
|
||||
}
|
||||
*(strrchr(path,'\\')+1)=0;
|
||||
|
|
Loading…
Add table
Reference in a new issue