diff --git a/configure.py b/configure.py index eaa5c416..8d4df0d8 100644 --- a/configure.py +++ b/configure.py @@ -1684,7 +1684,7 @@ config.libs = [ RVLSDKLib("fa", [ Object(Matching, "fa/pf_clib.c"), Object(Matching, "fa/pf_code.c"), - Object(NonMatching, "fa/pf_service.c"), + Object(Matching, "fa/pf_service.c"), Object(Matching, "fa/pf_str.c"), Object(Matching, "fa/pf_driver.c"), Object(NonMatching, "fa/pdm_api.c"), @@ -1733,15 +1733,15 @@ config.libs = [ Object(Matching, "fa/pf_ferror.c"), Object(NonMatching, "fa/pf_finfo.c"), Object(Matching, "fa/pf_flock.c"), - Object(NonMatching, "fa/pf_fopen.c"), + Object(Matching, "fa/pf_fopen.c"), Object(NonMatching, "fa/pf_format.c"), Object(Matching, "fa/pf_fread.c"), - Object(NonMatching, "fa/pf_fseek.c"), + Object(Matching, "fa/pf_fseek.c"), Object(NonMatching, "fa/pf_fsetclstlink.c"), Object(NonMatching, "fa/pf_fsexec.c"), - Object(NonMatching, "fa/pf_fsfirst.c"), - Object(NonMatching, "fa/pf_fsnext.c"), - Object(NonMatching, "fa/pf_fstat.c"), + Object(Matching, "fa/pf_fsfirst.c"), + Object(Matching, "fa/pf_fsnext.c"), + Object(Matching, "fa/pf_fstat.c"), Object(Matching, "fa/pf_fsync.c"), Object(Matching, "fa/pf_fwrite.c"), Object(NonMatching, "fa/pf_getdev.c"), diff --git a/libs/RVL_SDK/src/fa/pf_fopen.c b/libs/RVL_SDK/src/fa/pf_fopen.c index 251bdf44..d137ada1 100644 --- a/libs/RVL_SDK/src/fa/pf_fopen.c +++ b/libs/RVL_SDK/src/fa/pf_fopen.c @@ -1,38 +1,41 @@ -#define PF_FA_STR_LAYOUT -#define VFiPFAPI_ParseOpenModeString PFAPI_ParseOpenModeString -#define VFiPFAPI_convertReturnValue2NULL PFAPI_convertReturnValue2NULL -#define VFiPFFILE_fopen PFFILE_fopen -#define VFiPFSTR_InitStr PFSTR_InitStr -#include +#include -typedef struct PFAPI_GLOBAL_STATE { - pf_u8 volume_state[0x40]; - pf_s32 last_error; -} PFAPI_GLOBAL_STATE; -extern PFAPI_GLOBAL_STATE pf_vol_set; +typedef struct PFF2_STR { + const s8* p_head; + const s8* p_tail; + const s8* p_current; + u32 code_mode; +} PFF2_STR; +typedef struct PFF2_VOL_SET { + u8 reserved[0x40]; + s32 last_error; +} PFF2_VOL_SET; -#include -#include +extern PFF2_VOL_SET pf_vol_set; +extern s32 PFAPI_ParseOpenModeString(const char* mode_str); +extern s32 PFSTR_InitStr(PFF2_STR* path, const s8* text, u32 code_mode); +extern s32 PFFILE_fopen(PFF2_STR* path, s32 mode, FAFILE** result); +extern FAFILE* PFAPI_convertReturnValue2NULL(s32 err, FAFILE* p_stream); -PF_FILE* pf2_fopen(const pf_ch8* path, const pf_ch8* mode) { - pf_u32 open_mode; - PF_FILE* p_file; - PF_STR path_str; - pf_s32 err; +FAFILE* pf2_fopen(const char* path, const char* mode) { + u32 open_mode; + FAFILE* p_file; + PFF2_STR path_str; + s32 err; - open_mode = VFiPFAPI_ParseOpenModeString(mode); + open_mode = PFAPI_ParseOpenModeString(mode); if (open_mode == 0) { pf_vol_set.last_error = 10; - p_file = PF_NULL; + p_file = NULL; } else { - err = VFiPFSTR_InitStr(&path_str, (pf_s8*)path, 1U); + err = PFSTR_InitStr(&path_str, (const s8*)path, 1); if (err == 0) { - err = VFiPFFILE_fopen(&path_str, open_mode, &p_file); + err = PFFILE_fopen(&path_str, open_mode, &p_file); } else { pf_vol_set.last_error = err; } - p_file = VFiPFAPI_convertReturnValue2NULL(err, p_file); + p_file = PFAPI_convertReturnValue2NULL(err, p_file); } return p_file; } diff --git a/libs/RVL_SDK/src/fa/pf_fseek.c b/libs/RVL_SDK/src/fa/pf_fseek.c index b504cf24..9fcfad95 100644 --- a/libs/RVL_SDK/src/fa/pf_fseek.c +++ b/libs/RVL_SDK/src/fa/pf_fseek.c @@ -1,13 +1,10 @@ -#define PF_FA_STR_LAYOUT -#define VFiPFAPI_convertReturnValue PFAPI_convertReturnValue -#define VFiPFFILE_fseek PFFILE_fseek -#include +#include -#include -#include +extern s32 PFFILE_fseek(FAFILE* stream, s32 offset, int origin); +extern s32 PFAPI_convertReturnValue(s32 err); -pf_int32 pf2_fseek(PF_FILE* pFile, pf_s32 lOffset, pf_int32 nOrigin) { - pf_s32 err = VFiPFFILE_fseek(pFile, lOffset, nOrigin); - err = VFiPFAPI_convertReturnValue(err); +FAError pf2_fseek(FAFILE* stream, s32 offset, int origin) { + s32 err = PFFILE_fseek(stream, offset, origin); + err = PFAPI_convertReturnValue(err); return err; } diff --git a/libs/RVL_SDK/src/fa/pf_fsfirst.c b/libs/RVL_SDK/src/fa/pf_fsfirst.c index 01ad1f47..df29f5aa 100644 --- a/libs/RVL_SDK/src/fa/pf_fsfirst.c +++ b/libs/RVL_SDK/src/fa/pf_fsfirst.c @@ -1,30 +1,32 @@ -#define PF_FA_STR_LAYOUT -#define VFiPFAPI_convertReturnValue PFAPI_convertReturnValue -#define VFiPFDIR_fsfirst PFDIR_fsfirst -#define VFiPFSTR_InitStr PFSTR_InitStr -#include +#include -typedef struct PFAPI_GLOBAL_STATE { - pf_u8 volume_state[0x40]; - pf_s32 last_error; -} PFAPI_GLOBAL_STATE; -extern PFAPI_GLOBAL_STATE pf_vol_set; +typedef struct PFF2_STR { + const s8* p_head; + const s8* p_tail; + const s8* p_current; + u32 code_mode; +} PFF2_STR; +typedef struct PFF2_VOL_SET { + u8 reserved[0x40]; + s32 last_error; +} PFF2_VOL_SET; -#include -#include +extern PFF2_VOL_SET pf_vol_set; +extern s32 PFSTR_InitStr(PFF2_STR* path, const s8* text, u32 code_mode); +extern s32 PFDIR_fsfirst(PFF2_STR* path, u8 attributes, FADta* data); +extern s32 PFAPI_convertReturnValue(s32 err); -pf_int32 pf2_fsfirst(const pf_ch8* path, pf_u8 attrs, PF_DTA* p_dta) { - pf_s32 err; - PF_STR path_str; +FAError pf2_fsfirst(const char* dirName, u8 attr, FADta* dta) { + s32 err; + PFF2_STR path_str; - err = VFiPFSTR_InitStr(&path_str, (pf_s8*)path, 1U); + err = PFSTR_InitStr(&path_str, (const s8*)dirName, 1); if (err == 0) { - err = VFiPFDIR_fsfirst(&path_str, attrs, p_dta); + err = PFDIR_fsfirst(&path_str, attr, dta); } else { pf_vol_set.last_error = err; } - err = VFiPFAPI_convertReturnValue(err); - + err = PFAPI_convertReturnValue(err); return err; } diff --git a/libs/RVL_SDK/src/fa/pf_fsnext.c b/libs/RVL_SDK/src/fa/pf_fsnext.c index 4bf035eb..9675453d 100644 --- a/libs/RVL_SDK/src/fa/pf_fsnext.c +++ b/libs/RVL_SDK/src/fa/pf_fsnext.c @@ -1,15 +1,10 @@ -#define PF_FA_STR_LAYOUT -#define VFiPFAPI_convertReturnValue PFAPI_convertReturnValue -#define VFiPFDIR_fsnext PFDIR_fsnext -#include +#include -#include -#include +extern s32 PFDIR_fsnext(FADta* data); +extern s32 PFAPI_convertReturnValue(s32 err); -pf_int32 pf2_fsnext(PF_DTA* p_dta) { - pf_s32 err; - - err = VFiPFDIR_fsnext(p_dta); - err = VFiPFAPI_convertReturnValue(err); +FAError pf2_fsnext(FADta* dta) { + s32 err = PFDIR_fsnext(dta); + err = PFAPI_convertReturnValue(err); return err; } diff --git a/libs/RVL_SDK/src/fa/pf_fstat.c b/libs/RVL_SDK/src/fa/pf_fstat.c new file mode 100644 index 00000000..ea96aff3 --- /dev/null +++ b/libs/RVL_SDK/src/fa/pf_fstat.c @@ -0,0 +1,32 @@ +#include + +typedef struct PFF2_STR { + const s8* p_head; + const s8* p_tail; + const s8* p_current; + u32 code_mode; +} PFF2_STR; + +typedef struct PFF2_VOL_SET { + u8 reserved[0x40]; + s32 last_error; +} PFF2_VOL_SET; + +extern PFF2_VOL_SET pf_vol_set; +extern s32 PFSTR_InitStr(PFF2_STR* path, const s8* text, u32 code_mode); +extern s32 PFDIR_fstat(PFF2_STR* path, FAFileStat* file_stat); +extern s32 PFAPI_convertReturnValue(s32 err); + +FAError pf2_fstat(const char* fileName, FAFileStat* stat) { + s32 err; + PFF2_STR path_str; + + err = PFSTR_InitStr(&path_str, (const s8*)fileName, 1); + if (err == 0) { + err = PFDIR_fstat(&path_str, stat); + } else { + pf_vol_set.last_error = err; + } + err = PFAPI_convertReturnValue(err); + return err; +}