Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168206926
D14417.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D14417.diff
View Options
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)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Aug 27, 9:42 PM (9 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37419418
Default Alt Text
D14417.diff (1 KB)
Attached To
Mode
D14417: liblua: Emulate DIR, opendir, fdopendir, closedir
Attached
Detach File
Event Timeline
Log In to Comment