loader: use fsMakePath

This commit is contained in:
TuxSH 2021-04-30 19:01:13 +01:00
parent 4ae4d16dba
commit 50c81f8165
3 changed files with 8 additions and 14 deletions

View File

@ -15,7 +15,7 @@ namespace util
{ {
inline FS_Path MakePath(const char *path) inline FS_Path MakePath(const char *path)
{ {
return {PATH_ASCII, strnlen(path, 255) + 1, path}; return fsMakePath(PATH_ASCII, path);
} }
// A small wrapper to make forgetting to close a file and // A small wrapper to make forgetting to close a file and

View File

@ -28,12 +28,9 @@ static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, s3
return i; return i;
} }
Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags) static Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, u32 flags)
{ {
FS_Path filePath = {PATH_ASCII, strnlen(path, 255) + 1, path}, return IFile_Open(file, archiveId, fsMakePath(PATH_ASCII, path), fsMakePath(PATH_EMPTY, ""), flags);
archivePath = {PATH_EMPTY, 1, (u8 *)""};
return IFile_Open(file, archiveId, archivePath, filePath, flags);
} }
static bool dirCheck(FS_ArchiveID archiveId, const char *path) static bool dirCheck(FS_ArchiveID archiveId, const char *path)
@ -41,13 +38,11 @@ static bool dirCheck(FS_ArchiveID archiveId, const char *path)
bool ret; bool ret;
Handle handle; Handle handle;
FS_Archive archive; FS_Archive archive;
FS_Path dirPath = {PATH_ASCII, strnlen(path, 255) + 1, path},
archivePath = {PATH_EMPTY, 1, (u8 *)""};
if(R_FAILED(FSUSER_OpenArchive(&archive, archiveId, archivePath))) ret = false; if(R_FAILED(FSUSER_OpenArchive(&archive, archiveId, fsMakePath(PATH_EMPTY, "")))) ret = false;
else else
{ {
ret = R_SUCCEEDED(FSUSER_OpenDirectory(&handle, archive, dirPath)); ret = R_SUCCEEDED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_ASCII, path)));
if(ret) FSDIR_Close(handle); if(ret) FSDIR_Close(handle);
FSUSER_CloseArchive(archive); FSUSER_CloseArchive(archive);
} }
@ -519,7 +514,7 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize,
//Locate update RomFSes //Locate update RomFSes
for(updateRomFsIndex = 0; updateRomFsIndex < sizeof(updateRomFsMounts) / sizeof(char *) - 1; updateRomFsIndex++) for(updateRomFsIndex = 0; updateRomFsIndex < sizeof(updateRomFsMounts) / sizeof(char *) - 1; updateRomFsIndex++)
{ {
u32 patternSize = strnlen(updateRomFsMounts[updateRomFsIndex], 255); u32 patternSize = strlen(updateRomFsMounts[updateRomFsIndex]);
u8 temp[7]; u8 temp[7];
temp[0] = 0; temp[0] = 0;
memcpy(temp + 1, updateRomFsMounts[updateRomFsIndex], patternSize); memcpy(temp + 1, updateRomFsMounts[updateRomFsIndex], patternSize);

View File

@ -43,6 +43,5 @@ extern u32 config, multiConfig, bootConfig;
extern bool isN3DS, isSdMode; extern bool isN3DS, isSdMode;
void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress); void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress);
Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags);
bool loadTitleCodeSection(u64 progId, u8 *code, u32 size); bool loadTitleCodeSection(u64 progId, u8 *code, u32 size);
bool loadTitleExheaderInfo(u64 progId, ExHeader_Info *exheaderInfo); bool loadTitleExheaderInfo(u64 progId, ExHeader_Info *exheaderInfo);