2018-06-13 14:36:15 +02:00
|
|
|
#include "devoptab_sd.h"
|
2018-05-27 13:11:45 +02:00
|
|
|
|
|
|
|
char *
|
|
|
|
__wut_fs_fixpath(struct _reent *r,
|
|
|
|
const char *path)
|
|
|
|
{
|
2018-06-13 18:36:12 +02:00
|
|
|
char *p = strchr(path, ':') + 1;
|
2018-05-27 13:11:45 +02:00
|
|
|
|
2018-06-13 18:36:12 +02:00
|
|
|
if (!strchr(path, ':')) {
|
2018-05-27 13:11:45 +02:00
|
|
|
p = (char*)path;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(p) > PATH_MAX) {
|
|
|
|
r->_errno = ENAMETOOLONG;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-13 18:36:12 +02:00
|
|
|
char *__fixedpath = memalign(0x40, PATH_MAX + 1);
|
2018-05-27 13:11:45 +02:00
|
|
|
|
|
|
|
if (__fixedpath == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-13 18:36:12 +02:00
|
|
|
// cwd is handled by coreinit, so just strip the 'device:' if it exists
|
2018-05-27 13:11:45 +02:00
|
|
|
strcpy(__fixedpath, p);
|
|
|
|
return __fixedpath;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
__wut_fs_translate_error(FSStatus error)
|
|
|
|
{
|
|
|
|
switch (error) {
|
|
|
|
case FS_STATUS_CANCELLED:
|
|
|
|
return EINVAL;
|
|
|
|
case FS_STATUS_EXISTS:
|
|
|
|
return EEXIST;
|
|
|
|
case FS_STATUS_NOT_FOUND:
|
|
|
|
return ENOENT;
|
|
|
|
case FS_STATUS_STORAGE_FULL:
|
|
|
|
return ENOSPC;
|
|
|
|
case FS_ERROR_INVALID_PATH:
|
|
|
|
return ENAMETOOLONG;
|
|
|
|
default:
|
|
|
|
return (int)error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|