mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 03:04:16 +01:00
Rename wutdevoptab to wutdevoptab_sd
This commit is contained in:
parent
c2a993a4dd
commit
865af4609c
@ -5,6 +5,6 @@ add_subdirectory(libgfd)
|
||||
add_subdirectory(libwhb)
|
||||
add_subdirectory(nn_swkbd)
|
||||
add_subdirectory(wutcrt)
|
||||
add_subdirectory(wutdevoptab)
|
||||
add_subdirectory(wutdevoptab_sd)
|
||||
add_subdirectory(wutnewlib)
|
||||
add_subdirectory(wutstdc++)
|
||||
|
@ -1,8 +1,8 @@
|
||||
extern void __init_wut_devoptab_sd() __attribute__((weak));
|
||||
extern void __init_wut_newlib() __attribute__((weak));
|
||||
extern void __init_wut_devoptab() __attribute__((weak));
|
||||
extern void __init_wut_stdcpp() __attribute__((weak));
|
||||
|
||||
extern void __fini_wut_devoptab() __attribute__((weak));
|
||||
extern void __fini_wut_devoptab_sd() __attribute__((weak));
|
||||
extern void __fini_wut_newlib() __attribute__((weak));
|
||||
extern void __fini_wut_stdcpp() __attribute__((weak));
|
||||
|
||||
@ -13,8 +13,8 @@ __init_wut()
|
||||
__init_wut_newlib();
|
||||
}
|
||||
|
||||
if (__init_wut_devoptab) {
|
||||
__init_wut_devoptab();
|
||||
if (__init_wut_devoptab_sd) {
|
||||
__init_wut_devoptab_sd();
|
||||
}
|
||||
|
||||
if (__init_wut_stdcpp) {
|
||||
@ -29,8 +29,8 @@ __fini_wut()
|
||||
__fini_wut_stdcpp();
|
||||
}
|
||||
|
||||
if (__fini_wut_devoptab) {
|
||||
__fini_wut_devoptab();
|
||||
if (__fini_wut_devoptab_sd) {
|
||||
__fini_wut_devoptab_sd();
|
||||
}
|
||||
|
||||
if (__fini_wut_newlib) {
|
||||
|
@ -1,34 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wutdevoptab C)
|
||||
|
||||
add_library(wutdevoptab
|
||||
devoptab_fs.c
|
||||
devoptab_fs_chdir.c
|
||||
devoptab_fs_chmod.c
|
||||
devoptab_fs_close.c
|
||||
devoptab_fs_dirclose.c
|
||||
devoptab_fs_dirnext.c
|
||||
devoptab_fs_diropen.c
|
||||
devoptab_fs_dirreset.c
|
||||
devoptab_fs_fchmod.c
|
||||
devoptab_fs_fstat.c
|
||||
devoptab_fs_fsync.c
|
||||
devoptab_fs_getmtime.c
|
||||
devoptab_fs_link.c
|
||||
devoptab_fs_mkdir.c
|
||||
devoptab_fs_open.c
|
||||
devoptab_fs_read.c
|
||||
devoptab_fs_rename.c
|
||||
devoptab_fs_rmdir.c
|
||||
devoptab_fs_seek.c
|
||||
devoptab_fs_stat.c
|
||||
devoptab_fs_statvfs.c
|
||||
devoptab_fs_truncate.c
|
||||
devoptab_fs_unlink.c
|
||||
devoptab_fs_utils.c
|
||||
devoptab_fs_write.c)
|
||||
|
||||
target_include_directories(wutdevoptab PRIVATE "${WUT_ROOT}/include")
|
||||
|
||||
install(TARGETS wutdevoptab
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
34
libraries/wutdevoptab_sd/CMakeLists.txt
Normal file
34
libraries/wutdevoptab_sd/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(wutdevoptab_sd C)
|
||||
|
||||
add_library(wutdevoptab_sd
|
||||
devoptab_sd.c
|
||||
devoptab_sd_chdir.c
|
||||
devoptab_sd_chmod.c
|
||||
devoptab_sd_close.c
|
||||
devoptab_sd_dirclose.c
|
||||
devoptab_sd_dirnext.c
|
||||
devoptab_sd_diropen.c
|
||||
devoptab_sd_dirreset.c
|
||||
devoptab_sd_fchmod.c
|
||||
devoptab_sd_fstat.c
|
||||
devoptab_sd_fsync.c
|
||||
devoptab_sd_getmtime.c
|
||||
devoptab_sd_link.c
|
||||
devoptab_sd_mkdir.c
|
||||
devoptab_sd_open.c
|
||||
devoptab_sd_read.c
|
||||
devoptab_sd_rename.c
|
||||
devoptab_sd_rmdir.c
|
||||
devoptab_sd_seek.c
|
||||
devoptab_sd_stat.c
|
||||
devoptab_sd_statvfs.c
|
||||
devoptab_sd_truncate.c
|
||||
devoptab_sd_unlink.c
|
||||
devoptab_sd_utils.c
|
||||
devoptab_sd_write.c)
|
||||
|
||||
target_include_directories(wutdevoptab_sd PRIVATE "${WUT_ROOT}/include")
|
||||
|
||||
install(TARGETS wutdevoptab_sd
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
char *
|
||||
__wut_fs_fixpath(struct _reent *r,
|
@ -1,9 +1,9 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
static devoptab_t
|
||||
__wut_fs_devoptab =
|
||||
{
|
||||
.name = "fs",
|
||||
.name = "sd",
|
||||
.structSize = sizeof(__wut_fs_file_t),
|
||||
.open_r = __wut_fs_open,
|
||||
.close_r = __wut_fs_close,
|
||||
@ -29,16 +29,18 @@ __wut_fs_devoptab =
|
||||
.chmod_r = __wut_fs_chmod,
|
||||
.fchmod_r = __wut_fs_fchmod,
|
||||
.rmdir_r = __wut_fs_rmdir,
|
||||
// .lstat_r
|
||||
// .utimes_r
|
||||
};
|
||||
|
||||
FSClient *
|
||||
__wut_devoptab_fs_client = NULL;
|
||||
__wut_devoptab_sd_client = NULL;
|
||||
|
||||
static bool
|
||||
__wut_fs_initialised = false;
|
||||
|
||||
FSStatus
|
||||
__init_wut_devoptab()
|
||||
__init_wut_devoptab_sd()
|
||||
{
|
||||
FSStatus rc = 0;
|
||||
|
||||
@ -46,17 +48,17 @@ __init_wut_devoptab()
|
||||
return rc;
|
||||
}
|
||||
|
||||
__wut_devoptab_fs_client = memalign(0x20, sizeof(FSClient));
|
||||
__wut_devoptab_sd_client = memalign(0x20, sizeof(FSClient));
|
||||
FSCmdBlock fsCmd;
|
||||
FSMountSource mountSource;
|
||||
char mountPath[0x80];
|
||||
char workDir[0x83];
|
||||
|
||||
FSInit();
|
||||
rc = FSAddClient(__wut_devoptab_fs_client, -1);
|
||||
rc = FSAddClient(__wut_devoptab_sd_client, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
free(__wut_devoptab_fs_client);
|
||||
free(__wut_devoptab_sd_client);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -70,23 +72,23 @@ __init_wut_devoptab()
|
||||
__wut_fs_initialised = true;
|
||||
|
||||
// Mount the SD card
|
||||
rc = FSGetMountSource(__wut_devoptab_fs_client, &fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||
rc = FSGetMountSource(__wut_devoptab_sd_client, &fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = FSMount(__wut_devoptab_fs_client, &fsCmd, &mountSource, mountPath, 0x80, -1);
|
||||
rc = FSMount(__wut_devoptab_sd_client, &fsCmd, &mountSource, mountPath, 0x80, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
// chdir to SD root for general use
|
||||
strcpy(workDir, "fs:");
|
||||
strcpy(workDir, "sd:");
|
||||
strcat(workDir, mountPath);
|
||||
chdir(workDir);
|
||||
}
|
||||
} else {
|
||||
FSDelClient(__wut_devoptab_fs_client, -1);
|
||||
free(__wut_devoptab_fs_client);
|
||||
FSDelClient(__wut_devoptab_sd_client, -1);
|
||||
free(__wut_devoptab_sd_client);
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
@ -95,7 +97,7 @@ __init_wut_devoptab()
|
||||
}
|
||||
|
||||
FSStatus
|
||||
__fini_wut_devoptab()
|
||||
__fini_wut_devoptab_sd()
|
||||
{
|
||||
FSStatus rc = 0;
|
||||
|
||||
@ -103,7 +105,7 @@ __fini_wut_devoptab()
|
||||
return rc;
|
||||
}
|
||||
|
||||
FSDelClient(__wut_devoptab_fs_client, -1);
|
||||
free(__wut_devoptab_fs_client);
|
||||
FSDelClient(__wut_devoptab_sd_client, -1);
|
||||
free(__wut_devoptab_sd_client);
|
||||
return rc;
|
||||
}
|
@ -46,7 +46,7 @@ typedef struct
|
||||
#define FS_DIRITER_MAGIC 0x77696975
|
||||
|
||||
extern FSClient *
|
||||
__wut_devoptab_fs_client;
|
||||
__wut_devoptab_sd_client;
|
||||
|
||||
int __wut_fs_open(struct _reent *r, void *fileStruct, const char *path,
|
||||
int flags, int mode);
|
||||
@ -78,6 +78,6 @@ int __wut_fs_chmod(struct _reent *r, const char *path, mode_t mode);
|
||||
int __wut_fs_fchmod(struct _reent *r, void *fd, mode_t mode);
|
||||
int __wut_fs_rmdir(struct _reent *r, const char *name);
|
||||
|
||||
// devoptab_fs_utils.c
|
||||
// devoptab_sd_utils.c
|
||||
char * __wut_fs_fixpath(struct _reent *r, const char *path);
|
||||
int __wut_fs_translate_error(FSStatus error);
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_chdir(struct _reent *r,
|
||||
@ -21,7 +21,7 @@ __wut_fs_chdir(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSChangeDir(__wut_devoptab_fs_client, &fsCmd, path, -1);
|
||||
rc = FSChangeDir(__wut_devoptab_sd_client, &fsCmd, path, -1);
|
||||
free(path);
|
||||
|
||||
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_chmod(struct _reent *r,
|
||||
@ -17,7 +17,7 @@ __wut_fs_chmod(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSChangeMode(__wut_devoptab_fs_client, &fsCmd, path_fix, (FSMode)mode, -1);
|
||||
rc = FSChangeMode(__wut_devoptab_sd_client, &fsCmd, path_fix, (FSMode)mode, -1);
|
||||
free(path_fix);
|
||||
|
||||
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_close(struct _reent *r,
|
||||
@ -11,7 +11,7 @@ __wut_fs_close(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSCloseFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||
rc = FSCloseFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_dirclose(struct _reent *r,
|
||||
@ -11,7 +11,7 @@ __wut_fs_dirclose(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||
rc = FSCloseDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, -1);
|
||||
rc = FSCloseDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_dirnext(struct _reent *r,
|
||||
@ -15,7 +15,7 @@ __wut_fs_dirnext(struct _reent *r,
|
||||
|
||||
// Fetch the next dir
|
||||
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
||||
rc = FSReadDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, &dir->entry_data, -1);
|
||||
rc = FSReadDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, &dir->entry_data, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
// There are no more entries; ENOENT signals end-of-directory
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
DIR_ITER *
|
||||
__wut_fs_diropen(struct _reent *r,
|
||||
@ -24,7 +24,7 @@ __wut_fs_diropen(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||
rc = FSOpenDir(__wut_devoptab_fs_client, &fsCmd, path_fixed, &fd, -1);
|
||||
rc = FSOpenDir(__wut_devoptab_sd_client, &fsCmd, path_fixed, &fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
dir->magic = FS_DIRITER_MAGIC;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_dirreset(struct _reent *r,
|
||||
@ -11,7 +11,7 @@ __wut_fs_dirreset(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||
rc = FSRewindDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, -1);
|
||||
rc = FSRewindDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_fchmod(struct _reent *r,
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_fstat(struct _reent *r,
|
||||
@ -13,7 +13,7 @@ __wut_fs_fstat(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
memset(st, 0, sizeof(struct stat));
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_fsync(struct _reent *r,
|
||||
@ -11,7 +11,7 @@ __wut_fs_fsync(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSFlushFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||
rc = FSFlushFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_getmtime(const char *name,
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_link(struct _reent *r,
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_mkdir(struct _reent *r,
|
||||
@ -23,7 +23,7 @@ __wut_fs_mkdir(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
// TODO: Use mode to set directory attributes.
|
||||
rc = FSMakeDir(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||
rc = FSMakeDir(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
||||
free(path_fix);
|
||||
|
||||
if (rc == FS_ERROR_ALREADY_EXISTS) {
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_open(struct _reent *r,
|
||||
@ -48,12 +48,12 @@ __wut_fs_open(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
// Open the file
|
||||
rc = FSOpenFile(__wut_devoptab_fs_client, &fsCmd, path_fixed, fs_mode, &fd, -1);
|
||||
rc = FSOpenFile(__wut_devoptab_sd_client, &fsCmd, path_fixed, fs_mode, &fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
file->fd = fd;
|
||||
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
||||
FSGetPosFile(__wut_devoptab_fs_client, &fsCmd, fd, &file->offset, -1);
|
||||
FSGetPosFile(__wut_devoptab_sd_client, &fsCmd, fd, &file->offset, -1);
|
||||
free(path_fixed);
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
ssize_t
|
||||
__wut_fs_read(struct _reent *r,
|
||||
@ -21,7 +21,7 @@ __wut_fs_read(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
FSStat fsstat;
|
||||
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
|
||||
if(rc < 0) {
|
||||
r->_errno = __wut_fs_translate_error(rc);
|
||||
@ -39,7 +39,7 @@ __wut_fs_read(struct _reent *r,
|
||||
}
|
||||
|
||||
// Write the data
|
||||
rc = FSReadFile(__wut_devoptab_fs_client, &fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
||||
rc = FSReadFile(__wut_devoptab_sd_client, &fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
||||
|
||||
if(rc <= 0)
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_rename(struct _reent *r,
|
||||
@ -33,7 +33,7 @@ __wut_fs_rename(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSRename(__wut_devoptab_fs_client, &fsCmd, path_old, path_new, -1);
|
||||
rc = FSRename(__wut_devoptab_sd_client, &fsCmd, path_old, path_new, -1);
|
||||
free(path_old);
|
||||
free(path_new);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_rmdir(struct _reent *r,
|
||||
@ -21,7 +21,7 @@ __wut_fs_rmdir(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSRemove(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||
rc = FSRemove(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
||||
free(path_fix);
|
||||
|
||||
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
off_t
|
||||
__wut_fs_seek(struct _reent *r,
|
||||
@ -15,7 +15,7 @@ __wut_fs_seek(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
FSStat fsstat;
|
||||
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
r->_errno = __wut_fs_translate_error(rc);
|
||||
@ -54,7 +54,7 @@ __wut_fs_seek(struct _reent *r,
|
||||
|
||||
// Update the current offset
|
||||
file->offset = offset + pos;
|
||||
FSStatus result = FSSetPosFile(__wut_devoptab_fs_client, &fsCmd, file->fd, file->offset, -1);
|
||||
FSStatus result = FSSetPosFile(__wut_devoptab_sd_client, &fsCmd, file->fd, file->offset, -1);
|
||||
|
||||
if (result < 0) {
|
||||
return result;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_stat(struct _reent *r,
|
||||
@ -17,23 +17,23 @@ __wut_fs_stat(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
// First try open as file
|
||||
rc = FSOpenFile(__wut_devoptab_fs_client, &fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
||||
rc = FSOpenFile(__wut_devoptab_sd_client, &fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
__wut_fs_file_t tmpfd = { .fd = fd };
|
||||
rc = __wut_fs_fstat(r, &tmpfd, st);
|
||||
FSCloseFile(__wut_devoptab_fs_client, &fsCmd, fd, -1);
|
||||
FSCloseFile(__wut_devoptab_sd_client, &fsCmd, fd, -1);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// File failed, so lets try open as directory
|
||||
rc = FSOpenDir(__wut_devoptab_fs_client, &fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
||||
rc = FSOpenDir(__wut_devoptab_sd_client, &fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
memset(st, 0, sizeof(struct stat));
|
||||
st->st_nlink = 1;
|
||||
st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
FSCloseDir(__wut_devoptab_fs_client, &fsCmd, fd, -1);
|
||||
FSCloseDir(__wut_devoptab_sd_client, &fsCmd, fd, -1);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_statvfs(struct _reent *r,
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_ftruncate(struct _reent *r,
|
||||
@ -19,13 +19,13 @@ __wut_fs_ftruncate(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
// Set the new file size
|
||||
rc = FSSetPosFile(__wut_devoptab_fs_client, &fsCmd, file->fd, len, -1);
|
||||
rc = FSSetPosFile(__wut_devoptab_sd_client, &fsCmd, file->fd, len, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = FSTruncateFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||
rc = FSTruncateFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
||||
|
||||
if (rc >= 0) {
|
||||
return 0;
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
int
|
||||
__wut_fs_unlink(struct _reent *r,
|
||||
@ -21,7 +21,7 @@ __wut_fs_unlink(struct _reent *r,
|
||||
FSCmdBlock fsCmd;
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
rc = FSRemove(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||
rc = FSRemove(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
||||
free(path_fix);
|
||||
|
||||
if (rc >= 0) {
|
47
libraries/wutdevoptab_sd/devoptab_sd_utils.c
Normal file
47
libraries/wutdevoptab_sd/devoptab_sd_utils.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
char *
|
||||
__wut_fs_fixpath(struct _reent *r,
|
||||
const char *path)
|
||||
{
|
||||
char *p = strchr(path, ':')+1;
|
||||
|
||||
if(!strchr(path, ':')) {
|
||||
p = (char*)path;
|
||||
}
|
||||
|
||||
if (strlen(p) > PATH_MAX) {
|
||||
r->_errno = ENAMETOOLONG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *__fixedpath = memalign(0x40, PATH_MAX+1);
|
||||
|
||||
if (__fixedpath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// cwd is handled by coreinit, so just strip the 'fs:' if it exists
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "devoptab_fs.h"
|
||||
#include "devoptab_sd.h"
|
||||
|
||||
ssize_t
|
||||
__wut_fs_write(struct _reent *r,
|
||||
@ -34,7 +34,7 @@ __wut_fs_write(struct _reent *r,
|
||||
FSInitCmdBlock(&fsCmd);
|
||||
|
||||
// Write the data
|
||||
rc = FSWriteFile(__wut_devoptab_fs_client, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
||||
rc = FSWriteFile(__wut_devoptab_sd_client, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
free(tmp_buffer);
|
Loading…
Reference in New Issue
Block a user