! Open a directory * * @param[in,out] r newlib reentrancy struct * @param[in] dirState Pointer to open directory state * @param[in] path Path of directory to open * * @returns dirState for success * @returns NULL for error */
| 1041 | * @returns NULL for error |
| 1042 | */ |
| 1043 | static DIR_ITER* |
| 1044 | archive_diropen(struct _reent *r, |
| 1045 | DIR_ITER *dirState, |
| 1046 | const char *path) |
| 1047 | { |
| 1048 | Handle fd; |
| 1049 | Result rc; |
| 1050 | FS_Path fs_path; |
| 1051 | archive_fsdevice *device = r->deviceData; |
| 1052 | |
| 1053 | fs_path = archive_utf16path(r, path, &device); |
| 1054 | |
| 1055 | if(fs_path.data == NULL) |
| 1056 | return NULL; |
| 1057 | |
| 1058 | /* get pointer to our data */ |
| 1059 | archive_dir_t *dir = (archive_dir_t*)(dirState->dirStruct); |
| 1060 | |
| 1061 | /* open the directory */ |
| 1062 | rc = FSUSER_OpenDirectory(&fd, device->archive, fs_path); |
| 1063 | if(R_SUCCEEDED(rc)) |
| 1064 | { |
| 1065 | dir->magic = ARCHIVE_DIRITER_MAGIC; |
| 1066 | dir->fd = fd; |
| 1067 | dir->index = -1; |
| 1068 | dir->size = 0; |
| 1069 | memset(&dir->entry_data, 0, sizeof(dir->entry_data)); |
| 1070 | return dirState; |
| 1071 | } |
| 1072 | |
| 1073 | r->_errno = archive_translate_error(rc); |
| 1074 | return NULL; |
| 1075 | } |
| 1076 | |
| 1077 | /*! Fetch the next entry of an open directory |
| 1078 | * |
nothing calls this directly
no test coverage detected