2018-06-13 14:36:15 +02:00
|
|
|
#include "devoptab_sd.h"
|
2018-05-27 13:11:45 +02:00
|
|
|
|
|
|
|
DIR_ITER *
|
|
|
|
__wut_fs_diropen(struct _reent *r,
|
|
|
|
DIR_ITER *dirState,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
FSDirectoryHandle fd;
|
|
|
|
FSStatus rc;
|
|
|
|
|
|
|
|
if (path == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *path_fixed = __wut_fs_fixpath(r,path);
|
|
|
|
|
|
|
|
if (!path_fixed) {
|
|
|
|
r->_errno = ENOMEM;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up command block
|
|
|
|
FSCmdBlock fsCmd;
|
|
|
|
FSInitCmdBlock(&fsCmd);
|
|
|
|
|
|
|
|
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
2018-06-13 14:36:15 +02:00
|
|
|
rc = FSOpenDir(__wut_devoptab_sd_client, &fsCmd, path_fixed, &fd, -1);
|
2018-05-27 13:11:45 +02:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
dir->magic = FS_DIRITER_MAGIC;
|
|
|
|
dir->fd = fd;
|
|
|
|
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
|
|
|
free(path_fixed);
|
|
|
|
return dirState;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(path_fixed);
|
|
|
|
r->_errno = __wut_fs_translate_error(rc);
|
|
|
|
return NULL;
|
|
|
|
}
|