Index: head/stand/liblua/lstd.h =================================================================== --- head/stand/liblua/lstd.h +++ head/stand/liblua/lstd.h @@ -43,6 +43,11 @@ size_t size; } FILE; +typedef struct DIR +{ + int fd; +} DIR; + FILE *fopen(const char *filename, const char *mode); FILE *freopen( const char *filename, const char *mode, FILE *stream); size_t fread(void *ptr, size_t size, size_t count, FILE *stream); @@ -50,6 +55,9 @@ int ferror(FILE *stream); int feof(FILE *stream); int getc(FILE * stream); +DIR *opendir(const char *name); +DIR *fdopendir(int fd); +int closedir(DIR *); #ifndef EOF #define EOF (-1) Index: head/stand/liblua/lstd.c =================================================================== --- head/stand/liblua/lstd.c +++ head/stand/liblua/lstd.c @@ -127,6 +127,42 @@ return EOF; } +DIR * +opendir(const char *name) +{ + DIR *dp; + int fd; + + fd = open(name, O_RDONLY); + if (fd < 0) + return NULL; + dp = fdopendir(fd); + if (dp == NULL) + close(fd); + return dp; +} + +DIR * +fdopendir(int fd) +{ + DIR *dp; + + dp = malloc(sizeof(*dp)); + if (dp == NULL) + return NULL; + dp->fd = fd; + return dp; +} + +int +closedir(DIR *dp) +{ + close(dp->fd); + dp->fd = -1; + free(dp); + return 0; +} + void luai_writestring(const char *s, int i) {