Print volume/drive label in 'dir' cmd
This is in line with any other implementation of 'dir' command. It's also very useful for identifying e.g. which floppy is currently mounted. MS-DOS and cmd.exe display Volume Serial Number, but it emulating it in DOSBox doesn't seem to be very useful.
This commit is contained in:
parent
c3e7997f75
commit
64949a6e8c
2 changed files with 22 additions and 1 deletions
|
@ -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");
|
||||
|
|
|
@ -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 <path>'
|
||||
// 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;
|
||||
|
|
Loading…
Add table
Reference in a new issue