1
0
Fork 0

Give some hints when we are on Z:\, but not on other drives.

Always return the directory for the drive if the drive exists.
Fixes/improves bug 390.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3888
This commit is contained in:
Peter Veenstra 2015-01-09 10:50:17 +00:00
parent 401d129694
commit 017fda9ba0
2 changed files with 17 additions and 6 deletions

View file

@ -462,7 +462,7 @@ void SHELL_Init() {
MSG_Add("SHELL_ILLEGAL_SWITCH","Illegal switch: %s.\n");
MSG_Add("SHELL_MISSING_PARAMETER","Required parameter missing.\n");
MSG_Add("SHELL_CMD_CHDIR_ERROR","Unable to change to: %s.\n");
MSG_Add("SHELL_CMD_CHDIR_HINT","To change to different drive type \033[31m%c:\033[0m\n");
MSG_Add("SHELL_CMD_CHDIR_HINT","Hint: To change to different drive type \033[31m%c:\033[0m\n");
MSG_Add("SHELL_CMD_CHDIR_HINT_2","directoryname is longer than 8 characters and/or contains spaces.\nTry \033[31mcd %s\033[0m\n");
MSG_Add("SHELL_CMD_CHDIR_HINT_3","You are still on drive Z:, change to a mounted drive with \033[31mC:\033[0m.\n");
MSG_Add("SHELL_CMD_DATE_HELP","Displays or changes the internal date.\n");

View file

@ -303,13 +303,25 @@ void DOS_Shell::CMD_EXIT(char * args) {
void DOS_Shell::CMD_CHDIR(char * args) {
HELP("CHDIR");
StripSpaces(args);
Bit8u drive = DOS_GetDefaultDrive()+'A';
char dir[DOS_PATHLENGTH];
if (!*args) {
Bit8u drive=DOS_GetDefaultDrive()+'A';
char dir[DOS_PATHLENGTH];
DOS_GetCurrentDir(0,dir);
WriteOut("%c:\\%s\n",drive,dir);
} else if(strlen(args) == 2 && args[1]==':') {
WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(*reinterpret_cast<unsigned char*>(&args[0])));
Bit8u targetdrive = (args[0] | 0x20)-'a' + 1;
unsigned char targetdisplay = *reinterpret_cast<unsigned char*>(&args[0]);
if(!DOS_GetCurrentDir(targetdrive,dir)) {
if(drive == 'Z') {
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(targetdisplay));
} else {
WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));
}
return;
}
WriteOut("%c:\\%s\n",toupper(targetdisplay),dir);
if(drive == 'Z')
WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(targetdisplay));
} else if (!DOS_ChangeDir(args)) {
/* Changedir failed. Check if the filename is longer then 8 and/or contains spaces */
@ -334,8 +346,7 @@ void DOS_Shell::CMD_CHDIR(char * args) {
temps += "~1";
WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temps.insert(0,slashpart).c_str());
} else {
Bit8u drive=DOS_GetDefaultDrive()+'A';
if (drive=='Z') {
if (drive == 'Z') {
WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_3"));
} else {
WriteOut(MSG_Get("SHELL_CMD_CHDIR_ERROR"),args);