1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-30 08:57:49 +00:00

Include the CBM disk label in the returned directory entries.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5797 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-07-30 19:01:45 +00:00
parent 3c9f722fbf
commit 470a4abcf2
2 changed files with 15 additions and 7 deletions

View File

@ -13,7 +13,7 @@
DIR* __fastcall__ opendir (register const char* name)
{
unsigned char buf[32];
unsigned char buf[2];
DIR* dir = 0;
DIR d;
@ -39,7 +39,7 @@ DIR* __fastcall__ opendir (register const char* name)
if (d.fd >= 0) {
/* Skip the disk header */
if (_dirread (&d, buf, 32)) {
if (_dirread (&d, buf, sizeof (buf))) {
/* Allocate memory for the DIR structure returned */
dir = malloc (sizeof (*dir));

View File

@ -18,8 +18,8 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
register unsigned char* b;
register unsigned char i;
register unsigned char count;
unsigned char s;
unsigned char j;
static unsigned char s;
static unsigned char j;
unsigned char buffer[0x40];
static struct dirent entry;
@ -78,9 +78,17 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
case 1:
/* Within file name */
if (*b == '"') {
/* End of file name found. */
entry.d_name[j] = '\0';
entry.d_namlen = j;
s = 2;
if (entry.d_off != 0) {
/* Proceed with file type */
s = 2;
} else {
/* This is a disk header, so we're done */
entry.d_type = _CBM_T_HEADER;
return &entry;
}
} else if (j < sizeof (entry.d_name) - 1) {
entry.d_name[j] = *b;
++j;
@ -105,8 +113,8 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
/* Distinguish DEL or DIR file type entries */
switch (*b) {
case 'e': break;
case 'i': entry.d_type = CBM_T_DIR; break;
default: entry.d_type = CBM_T_OTHER; break;
case 'i': entry.d_type = _CBM_T_DIR; break;
default: entry.d_type = _CBM_T_OTHER; break;
}
return &entry;
}