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 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include <windows.h> 20#include <io.h>
21#include <malloc.h>
21#include "file-win32.h" 22#include "file-win32.h"
22#include "file.h" 23#include "file.h"
23 24
@@ -30,11 +31,36 @@ DIR *opendir (
30 char *dirname // directory name 31 char *dirname // directory name
31 ) 32 )
32{ 33{
33 DIR *p = (DIR*)malloc(sizeof(DIR)); 34 DIR *p = (DIR*)malloc(sizeof(DIR));
34 if (_findfirst (dirname, &p) == -1) 35 struct _finddata_t fd;
36 if ((p->handle = _findfirst (dirname, &fd)) == -1)
35 { 37 {
36 free (p); 38 free (p);
37 return NULL; 39 return NULL;
38 } 40 }
39 return p; 41 return p;
42}
43
44// closedir
45// close directory
46int closedir (
47 DIR *dir // previously opened dir search
48 )
49{
50 free(dir);
51 return 0;
52}
53
54// read dir
55// read next entry in directory
56dirent *readdir (
57 DIR *dir
58 )
59{
60 struct _finddata_t fd;
61 if (_findnext (dir->handle, &fd) == -1)
62 return NULL;
63 memcpy (dir->fd.d_name, fd.name, 256);
64 dir->fd.d_reclen = sizeof (dirent);
65 return &dir->fd;
40} \ No newline at end of file 66} \ 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 @@
22 22
23#include <io.h> 23#include <io.h>
24 24
25typedef _finddata_t DIR; 25struct direnttag
26{
27 long d_ino; /* inode number */
28 long d_off; /* offset to the next dirent */
29 unsigned short d_reclen;/* length of this record */
30 unsigned char d_type; /* type of file */
31 char d_name[256]; /* filename */
32};
33typedef struct direnttag dirent;
26 34
27struct dirent 35struct DIRtag
28{ 36{
29 long __d_reserved[4]; 37 dirent fd;
30 unsigned short d_ino; /* Just for compatibility, it's junk */ 38 intptr_t handle;
31 char d_name[256]; /* FIXME: use NAME_MAX? */
32}; 39};
40typedef struct DIRtag DIR;
33 41
34#endif // #ifndef __FILE_WIN32_H__ \ No newline at end of file 42#endif // #ifndef __FILE_WIN32_H__ \ No newline at end of file