wut/libraries/wutdevoptab/devoptab_fs_rmdir.c
Crementif d621766b2f
devoptab: Implement various functions and fixes (#223)
- Improved error codes for unlink and rmdir regarding non-empty directories.
- Return ENOENT on empty strings since it softlocks the Wii U. Since the devoptab relies on the cwd it's pretty easy to run into with stuff like recursive path creation for example.
- Clean up open_r mode_t->string conversion
- Improved FSStat->mode_t conversion
- Add FSOpenFileEx and flags
2022-07-23 12:03:07 +02:00

30 lines
576 B
C

#include "devoptab_fs.h"
int
__wut_fs_rmdir(struct _reent *r,
const char *name)
{
FSStatus status;
FSCmdBlock cmd;
if (!name) {
r->_errno = EINVAL;
return -1;
}
char *fixedPath = __wut_fs_fixpath(r, name);
if (!fixedPath) {
return -1;
}
FSInitCmdBlock(&cmd);
status = FSRemove(__wut_devoptab_fs_client, &cmd, fixedPath, FS_ERROR_FLAG_ALL);
free(fixedPath);
if (status < 0) {
r->_errno = status == FS_STATUS_EXISTS ? ENOTEMPTY : __wut_fs_translate_error(status);
return -1;
}
return 0;
}