mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
updated directory functions, not fully working and untested yet
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@300 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
17947b7898
commit
66ff6214ae
2 changed files with 43 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -22,13 +22,21 @@
|
|||
|
||||
#include <io.h>
|
||||
|
||||
typedef _finddata_t DIR;
|
||||
|
||||
struct dirent
|
||||
struct direnttag
|
||||
{
|
||||
long __d_reserved[4];
|
||||
unsigned short d_ino; /* Just for compatibility, it's junk */
|
||||
char d_name[256]; /* FIXME: use NAME_MAX? */
|
||||
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 DIRtag
|
||||
{
|
||||
dirent fd;
|
||||
intptr_t handle;
|
||||
};
|
||||
typedef struct DIRtag DIR;
|
||||
|
||||
#endif // #ifndef __FILE_WIN32_H__
|
||||
Loading…
Add table
Add a link
Reference in a new issue