From f8733e94cf5e69f6eef8ecf428c33cefb273b4ee Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 12 Aug 2007 19:16:09 +0000 Subject: [PATCH] Some more hints in CHDIR Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2965 --- src/shell/shell.cpp | 3 ++- src/shell/shell_cmds.cpp | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 4328a5f3..f872da8c 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.cpp,v 1.86 2007-07-03 17:32:14 qbix79 Exp $ */ +/* $Id: shell.cpp,v 1.87 2007-08-12 19:16:09 qbix79 Exp $ */ #include #include @@ -439,6 +439,7 @@ void SHELL_Init() { 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_2","directoryname is longer than 8 charachters and/or contains spaces.\nTry \033[31mcd %s\033[0m\n"); MSG_Add("SHELL_CMD_MKDIR_ERROR","Unable to make: %s.\n"); MSG_Add("SHELL_CMD_RMDIR_ERROR","Unable to remove: %s.\n"); MSG_Add("SHELL_CMD_DEL_ERROR","Unable to delete: %s.\n"); diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 14fd0ad8..c9f04f5c 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_cmds.cpp,v 1.76 2007-06-14 08:23:46 qbix79 Exp $ */ +/* $Id: shell_cmds.cpp,v 1.77 2007-08-12 19:16:09 qbix79 Exp $ */ #include #include @@ -268,7 +268,24 @@ void DOS_Shell::CMD_CHDIR(char * args) { } else if(strlen(args) == 2 && args[1]==':') { WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(*reinterpret_cast(&args[0]))); } else if (!DOS_ChangeDir(args)) { - WriteOut(MSG_Get("SHELL_CMD_CHDIR_ERROR"),args); + /* Changedir failed. Check if the filename is longer then 8 and/or contains spaces */ + char temp[DOS_PATHLENGTH]; + safe_strncpy(temp,args,DOS_PATHLENGTH); + char* dot = strrchr(temp,'.'); + if(dot) *dot = 0; + dot = strrchr(temp,' '); + if(dot) { /* Contains spaces */ + *dot = 0; + if(strlen(temp) > 6) temp[6] = 0; + strcat(temp,"~1"); + WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temp); + } else if(strlen(temp) >8) { + temp[6] = 0; + strcat(temp,"~1"); + WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temp); + } else { + WriteOut(MSG_Get("SHELL_CMD_CHDIR_ERROR"),args); + } } };