diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 06e49523..bc739e06 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -581,6 +581,7 @@ void SHELL_Init() { MSG_Add("SHELL_CMD_GOTO_LABEL_NOT_FOUND","GOTO: Label %s not found.\n"); 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_VOLUME"," Volume in drive %c is %s\n"); MSG_Add("SHELL_CMD_DIR_INTRO"," Directory of %s\n"); MSG_Add("SHELL_CMD_DIR_BYTES_USED","%16d file(s) %17s bytes\n"); MSG_Add("SHELL_CMD_DIR_BYTES_FREE","%16d dir(s) %17s bytes free\n"); diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 636be6c7..debb9093 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -526,8 +526,28 @@ void DOS_Shell::CMD_DIR(char * args) { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH")); return; } - *(strrchr(path,'\\')+1)=0; + + // DIR cmd in DOS and cmd.exe format 'Directory of ' + // accordingly: + // - only directory part of pattern passed as an argument + // - do not append '\' to the directory name + // - for root directories/drives: append '\' to the name + char *last_dir_sep = strrchr(path, '\\'); + if (last_dir_sep == path + 2) + *(last_dir_sep + 1) = '\0'; + else + *last_dir_sep = '\0'; + + const char drive_letter = path[0]; + const size_t drive_idx = drive_letter - 'A'; + const bool print_label = (drive_letter >= 'A') && Drives[drive_idx]; + if (!optB) { + if (print_label) { + const char *label = Drives[drive_idx]->GetLabel(); + WriteOut(MSG_Get("SHELL_CMD_DIR_VOLUME"), drive_letter, label); + p_count += 1; + } WriteOut(MSG_Get("SHELL_CMD_DIR_INTRO"), path); WriteOut_NoParsing("\n"); p_count += 2;