mirror of
https://github.com/cc65/cc65.git
synced 2024-11-18 15:05:14 +00:00
ebca2991a3
called _cbm_filetype(). Added an assembler include file with the file type definitions from cbm.h. Added a first implementation of readdir() for the CBMs. git-svn-id: svn://svn.cc65.org/cc65/trunk@5669 b7a2c559-68d2-44c3-8de9-860c34a00d81
51 lines
948 B
C
51 lines
948 B
C
/*
|
|
* Ullrich von Bassewitz, 2012-05-30. Based on code by Groepaz.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include "dir.h"
|
|
|
|
|
|
|
|
DIR* __fastcall__ opendir (const char*)
|
|
{
|
|
DIR* dir = 0;
|
|
DIR d;
|
|
|
|
/* Setup file name and offset */
|
|
d.name[0] = '$';
|
|
d.name[1] = '\0';
|
|
d.off = 0;
|
|
|
|
/* Open the directory on disk for reading */
|
|
d.fd = open (d.name, O_RDONLY);
|
|
if (d.fd >= 0) {
|
|
|
|
/* Skip the disk header */
|
|
if (_dirskip (32, &d)) {
|
|
|
|
/* Allocate memory for the DIR structure returned */
|
|
dir = malloc (sizeof (*dir));
|
|
|
|
/* Copy the contents of d */
|
|
if (dir) {
|
|
memcpy (dir, &d, sizeof (d));
|
|
} else {
|
|
/* Set an appropriate error code */
|
|
errno = ENOMEM;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Done */
|
|
return dir;
|
|
}
|
|
|
|
|
|
|