From 66ff6214ae656bf7bb26f761c0826baf42986a62 Mon Sep 17 00:00:00 2001 From: Felix Arends Date: Sun, 28 Apr 2002 16:52:43 +0000 Subject: updated directory functions, not fully working and untested yet git-svn-id: svn://svn.rockbox.org/rockbox/trunk@300 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/win32/file-win32.c | 32 +++++++++++++++++++++++++++++--- uisimulator/win32/file-win32.h | 18 +++++++++++++----- 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 +#include +#include #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 -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 -- cgit v1.2.3