wut/libraries/wutdevoptab/devoptab_fs_chdir.c
James Benton 690bd6ccbd Revert "Rename wutdevoptab to wutdevoptab_sd"
This reverts commit 865af4609c49015c64f4092fd53315a1110b8042.
Turns out it is for whole filesystem. oops.
2018-07-19 08:51:40 +01:00

34 lines
531 B
C

#include "devoptab_fs.h"
int
__wut_fs_chdir(struct _reent *r,
const char *name)
{
FSStatus rc;
if (name == NULL) {
return -1;
}
char *path = __wut_fs_fixpath(r, name);
if (!path) {
r->_errno = ENOMEM;
return -1;
}
// Set up command block
FSCmdBlock fsCmd;
FSInitCmdBlock(&fsCmd);
rc = FSChangeDir(__wut_devoptab_fs_client, &fsCmd, path, -1);
free(path);
if (rc >= 0) {
return 0;
}
r->_errno = __wut_fs_translate_error(rc);
return -1;
}