mirror of
https://github.com/cc65/cc65.git
synced 2024-12-24 11:31:31 +00:00
Parse the name passed to opendir().
git-svn-id: svn://svn.cc65.org/cc65/trunk@5678 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
2a53124b15
commit
ea51c5a4e2
@ -11,15 +11,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DIR* __fastcall__ opendir (const char*)
|
DIR* __fastcall__ opendir (register const char* name)
|
||||||
{
|
{
|
||||||
unsigned char buf[32];
|
unsigned char buf[32];
|
||||||
DIR* dir = 0;
|
|
||||||
DIR d;
|
DIR d;
|
||||||
|
DIR* dir = 0;
|
||||||
|
|
||||||
/* Setup file name and offset */
|
/* Setup the actual file name that is sent to the disk. We accept "0:",
|
||||||
|
* "1:" and "." as directory names.
|
||||||
|
*/
|
||||||
d.name[0] = '$';
|
d.name[0] = '$';
|
||||||
|
if (name == 0 || name[0] == '\0' || (name[0] == '.' && name[1] == '\0')) {
|
||||||
d.name[1] = '\0';
|
d.name[1] = '\0';
|
||||||
|
} else if ((name[0] == '0' || name[0] == '1') && name[1] == ':' && name[2] == '\0') {
|
||||||
|
d.name[1] = name[0];
|
||||||
|
d.name[2] = '\0';
|
||||||
|
} else {
|
||||||
|
errno = EINVAL;
|
||||||
|
goto exitpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the offset of the first entry */
|
||||||
d.off = sizeof (buf);
|
d.off = sizeof (buf);
|
||||||
|
|
||||||
/* Open the directory on disk for reading */
|
/* Open the directory on disk for reading */
|
||||||
@ -42,6 +54,7 @@ DIR* __fastcall__ opendir (const char*)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exitpoint:
|
||||||
/* Done */
|
/* Done */
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user