Hack to show volume labels via DIR command

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

Hack to show volume labels via DIR command

Postby HunterZ » 2010-12-12 @ 18:59

DOS shows volume labels as part of the DIR command. I've been interested in seeing if DOSBox could show them that way as well, so I poked at the 0.74 source code a bit and added/changed the following:

shell_cmds.cpp:
/* Command uses dta so set it to our internal dta */
RealPt save_dta=dos.dta();
dos.dta(dos.tables.tempdta);
DOS_DTA dta(dos.dta());
bool ret=DOS_FindFirst(args,0xffff);// & ~DOS_ATTR_VOLUME);

if (!ret) {
if (!optB) WriteOut(MSG_Get("SHELL_CMD_FILE_NOT_FOUND"),args);
dos.dta(save_dta);
return;
}

do { /* File name and extension */
char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u date;Bit16u time;Bit8u attr;
dta.GetResult(name,size,date,time,attr);

if(attr&DOS_ATTR_VOLUME) {
if(!optB) {
if(strlen(name) > 0) {
WriteOut(MSG_Get("SHELL_CMD_DIR_LABEL"), path[0], name);
} else {
WriteOut(MSG_Get("SHELL_CMD_DIR_NOLABEL"), path[0]);
}
}
continue;
}

/* Skip non-directories if option AD is present */
if(optAD && !(attr&DOS_ATTR_DIRECTORY) ) continue;


shell.cpp:
MSG_Add("SHELL_CMD_DIR_INTRO","Directory of %s.\n");
MSG_Add("SHELL_CMD_DIR_LABEL","Volume in drive %c is %s.\n");
MSG_Add("SHELL_CMD_DIR_NOLABEL","Volume in drive %c has no label.\n");

MSG_Add("SHELL_CMD_DIR_BYTES_USED","%5d File(s) %17s Bytes.\n");


It sort of works as a hack, but there are a lot of issues:
- Volume label is output after pathname, while in real DOS it's the other way around.
- Label is shown for directories MOUNTed with no parameters or with -t floppy, but not -t cdrom.
- Label is shown for IMGMOUNTed CD-ROM image files, but seems to be displayed as an 8.3 filename.
- Label is not shown for IMGMOUNTed floppy images.

On a somewhat unrelated note, it seems weird that IMGMOUNT takes a -label argument in conjunction with -t iso, but when you try to use -label with -t floppy you get a nonsensical "Image file not found." message from DOSBox.
User avatar
HunterZ
l33t++
 
Posts: 6073
Joined: 2003-1-31 @ 19:04
Location: Seattle

Re: Hack to show volume labels via DIR command

Postby ripsaw8080 » 2010-12-12 @ 22:26

The attached patch performs a separate search for the volume label. Could also make a VOL command with a similar approach.
Attachments
dir_volume.diff
(2.07 KiB) Downloaded 366 times
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4188
Joined: 2006-4-25 @ 23:24

Re: Hack to show volume labels via DIR command

Postby Qbix » 2010-12-13 @ 07:49

I was thinking of having mount print the volume label if you call it without parameters.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10547
Joined: 2002-11-27 @ 14:50
Location: Fryslan


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 3 guests