! Create a directory * * @param[in,out] r newlib reentrancy struct * @param[in] path Path of directory to create * @param[in] mode Permissions of created directory * * @returns 0 for success * @returns -1 for error */
| 997 | * @returns -1 for error |
| 998 | */ |
| 999 | static int |
| 1000 | archive_mkdir(struct _reent *r, |
| 1001 | const char *path, |
| 1002 | int mode) |
| 1003 | { |
| 1004 | Result rc; |
| 1005 | FS_Path fs_path; |
| 1006 | archive_fsdevice *device = r->deviceData; |
| 1007 | |
| 1008 | /* treat extdata as read-only */ |
| 1009 | if(device->is_extdata) |
| 1010 | { |
| 1011 | r->_errno = ENOTSUP; |
| 1012 | return -1; |
| 1013 | } |
| 1014 | |
| 1015 | fs_path = archive_utf16path(r, path, &device); |
| 1016 | if(fs_path.data == NULL) |
| 1017 | return -1; |
| 1018 | |
| 1019 | /* TODO: Use mode to set directory attributes. */ |
| 1020 | |
| 1021 | rc = FSUSER_CreateDirectory(device->archive, fs_path, 0); |
| 1022 | if(rc == 0xC82044BE) |
| 1023 | { |
| 1024 | r->_errno = EEXIST; |
| 1025 | return -1; |
| 1026 | } |
| 1027 | else if(R_SUCCEEDED(rc)) |
| 1028 | return 0; |
| 1029 | |
| 1030 | r->_errno = archive_translate_error(rc); |
| 1031 | return -1; |
| 1032 | } |
| 1033 | |
| 1034 | /*! Open a directory |
| 1035 | * |
nothing calls this directly
no test coverage detected