From 017fda9ba0c455de13be725f79481788a4908e36 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Fri, 9 Jan 2015 10:50:17 +0000 Subject: [PATCH] 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 --- src/shell/shell.cpp | 2 +- src/shell/shell_cmds.cpp | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 997c8e11..f7f8a4b5 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -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"); diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 2fbfa618..731c3bc1 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -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(&args[0]))); + Bit8u targetdrive = (args[0] | 0x20)-'a' + 1; + unsigned char targetdisplay = *reinterpret_cast(&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);