summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uisimulator/win32/file-win32.c32
-rw-r--r--uisimulator/win32/file-win32.h18
2 files changed, 42 insertions, 8 deletions
diff --git a/uisimulator/win32/file-win32.c b/uisimulator/win32/file-win32.c
index 478df372d5..57431e92a2 100644
--- a/uisimulator/win32/file-win32.c
+++ b/uisimulator/win32/file-win32.c
@@ -17,7 +17,8 @@
*
****************************************************************************/
-#include <windows.h>
+#include <io.h>
+#include <malloc.h>
#include "file-win32.h"
#include "file.h"
@@ -30,11 +31,36 @@ DIR *opendir (
char *dirname // directory name
)
{
- DIR *p = (DIR*)malloc(sizeof(DIR));
- if (_findfirst (dirname, &p) == -1)
+ DIR *p = (DIR*)malloc(sizeof(DIR));
+ struct _finddata_t fd;
+ if ((p->handle = _findfirst (dirname, &fd)) == -1)
{
free (p);
return NULL;
}
return p;
+}
+
+// closedir
+// close directory
+int closedir (
+ DIR *dir // previously opened dir search
+ )
+{
+ free(dir);
+ return 0;
+}
+
+// read dir
+// read next entry in directory
+dirent *readdir (
+ DIR *dir
+ )
+{
+ struct _finddata_t fd;
+ if (_findnext (dir->handle, &fd) == -1)
+ return NULL;
+ memcpy (dir->fd.d_name, fd.name, 256);
+ dir->fd.d_reclen = sizeof (dirent);
+ return &dir->fd;
} \ No newline at end of file
diff --git a/uisimulator/win32/file-win32.h b/uisimulator/win32/file-win32.h
index 48ebfa8fb0..a89ee4319d 100644
--- a/uisimulator/win32/file-win32.h
+++ b/uisimulator/win32/file-win32.h
@@ -22,13 +22,21 @@
#include <io.h>
-typedef _finddata_t DIR;
+struct direnttag
+{
+ long d_ino; /* inode number */
+ long d_off; /* offset to the next dirent */
+ unsigned short d_reclen;/* length of this record */
+ unsigned char d_type; /* type of file */
+ char d_name[256]; /* filename */
+};
+typedef struct direnttag dirent;
-struct dirent
+struct DIRtag
{
- long __d_reserved[4];
- unsigned short d_ino; /* Just for compatibility, it's junk */
- char d_name[256]; /* FIXME: use NAME_MAX? */
+ dirent fd;
+ intptr_t handle;
};
+typedef struct DIRtag DIR;
#endif // #ifndef __FILE_WIN32_H__ \ No newline at end of file