! Change current working directory * * @param[in,out] r newlib reentrancy struct * @param[in] name Path to new working directory * * @returns 0 for success * @returns -1 for error */
| 888 | * @returns -1 for error |
| 889 | */ |
| 890 | static int |
| 891 | archive_chdir(struct _reent *r, |
| 892 | const char *name) |
| 893 | { |
| 894 | Handle fd; |
| 895 | Result rc; |
| 896 | FS_Path fs_path; |
| 897 | archive_fsdevice *device = r->deviceData; |
| 898 | |
| 899 | fs_path = archive_utf16path(r, name, &device); |
| 900 | if(fs_path.data == NULL) |
| 901 | return -1; |
| 902 | |
| 903 | rc = FSUSER_OpenDirectory(&fd, device->archive, fs_path); |
| 904 | if(R_SUCCEEDED(rc)) |
| 905 | { |
| 906 | FSDIR_Close(fd); |
| 907 | strncpy(device->cwd, __ctru_dev_path_buf, PATH_MAX + 1); |
| 908 | device->cwd[PATH_MAX] = '\0'; |
| 909 | return 0; |
| 910 | } |
| 911 | |
| 912 | r->_errno = archive_translate_error(rc); |
| 913 | return -1; |
| 914 | } |
| 915 | |
| 916 | /*! Rename a file |
| 917 | * |
nothing calls this directly
no test coverage detected