mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +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:
parent
3c9f722fbf
commit
470a4abcf2
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
DIR* __fastcall__ opendir (register const char* name)
|
DIR* __fastcall__ opendir (register const char* name)
|
||||||
{
|
{
|
||||||
unsigned char buf[32];
|
unsigned char buf[2];
|
||||||
DIR* dir = 0;
|
DIR* dir = 0;
|
||||||
DIR d;
|
DIR d;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ DIR* __fastcall__ opendir (register const char* name)
|
|||||||
if (d.fd >= 0) {
|
if (d.fd >= 0) {
|
||||||
|
|
||||||
/* Skip the disk header */
|
/* Skip the disk header */
|
||||||
if (_dirread (&d, buf, 32)) {
|
if (_dirread (&d, buf, sizeof (buf))) {
|
||||||
|
|
||||||
/* Allocate memory for the DIR structure returned */
|
/* Allocate memory for the DIR structure returned */
|
||||||
dir = malloc (sizeof (*dir));
|
dir = malloc (sizeof (*dir));
|
||||||
|
@ -18,8 +18,8 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
|||||||
register unsigned char* b;
|
register unsigned char* b;
|
||||||
register unsigned char i;
|
register unsigned char i;
|
||||||
register unsigned char count;
|
register unsigned char count;
|
||||||
unsigned char s;
|
static unsigned char s;
|
||||||
unsigned char j;
|
static unsigned char j;
|
||||||
unsigned char buffer[0x40];
|
unsigned char buffer[0x40];
|
||||||
static struct dirent entry;
|
static struct dirent entry;
|
||||||
|
|
||||||
@ -78,9 +78,17 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
|||||||
case 1:
|
case 1:
|
||||||
/* Within file name */
|
/* Within file name */
|
||||||
if (*b == '"') {
|
if (*b == '"') {
|
||||||
|
/* End of file name found. */
|
||||||
entry.d_name[j] = '\0';
|
entry.d_name[j] = '\0';
|
||||||
entry.d_namlen = j;
|
entry.d_namlen = j;
|
||||||
|
if (entry.d_off != 0) {
|
||||||
|
/* Proceed with file type */
|
||||||
s = 2;
|
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) {
|
} else if (j < sizeof (entry.d_name) - 1) {
|
||||||
entry.d_name[j] = *b;
|
entry.d_name[j] = *b;
|
||||||
++j;
|
++j;
|
||||||
@ -105,8 +113,8 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
|||||||
/* Distinguish DEL or DIR file type entries */
|
/* Distinguish DEL or DIR file type entries */
|
||||||
switch (*b) {
|
switch (*b) {
|
||||||
case 'e': break;
|
case 'e': break;
|
||||||
case 'i': entry.d_type = CBM_T_DIR; break;
|
case 'i': entry.d_type = _CBM_T_DIR; break;
|
||||||
default: entry.d_type = CBM_T_OTHER; break;
|
default: entry.d_type = _CBM_T_OTHER; break;
|
||||||
}
|
}
|
||||||
return &entry;
|
return &entry;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user