mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-03 00:39:14 +00:00
makerom: romfs
made fixes by enler platform independent
This commit is contained in:
+7
-2
@@ -3,8 +3,6 @@
|
||||
#include "utf.h"
|
||||
|
||||
/* This is mainly a FS interface for ROMFS generation */
|
||||
|
||||
|
||||
int fs_InitDir(u16 *path, u32 pathlen, fs_dir *dir);
|
||||
int fs_ManageDirSlot(fs_dir *dir);
|
||||
int fs_ManageFileSlot(fs_dir *dir);
|
||||
@@ -15,6 +13,13 @@ bool fs_EntryIsDirNav(fs_entry *entry);
|
||||
int fs_AddDir(fs_entry *entry, fs_dir *dir);
|
||||
int fs_AddFile(fs_entry *entry, fs_dir *dir);
|
||||
|
||||
int fs_u16StrLen(fs_romfs_char *str)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; str[i] != 0x0; i++ );
|
||||
return i;
|
||||
}
|
||||
|
||||
int fs_InitDir(u16 *path, u32 pathlen, fs_dir *dir)
|
||||
{
|
||||
dir->name_len = pathlen;
|
||||
|
||||
+2
-1
@@ -33,7 +33,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u16 *name;
|
||||
fs_romfs_char *name;
|
||||
u32 name_len;
|
||||
u64 size;
|
||||
FILE *fp;
|
||||
@@ -57,6 +57,7 @@ typedef struct
|
||||
int fs_u8String_to_u16String(u16 **dst, u32 *dst_len, u8 *src, u32 src_len);
|
||||
int fs_u16String_to_u16String(u16 **dst, u32 *dst_len, u16 *src, u32 src_len);
|
||||
int fs_u32String_to_u16String(u16 **dst, u32 *dst_len, u32 *src, u32 src_len);
|
||||
int fs_u16StrLen(fs_romfs_char *str);
|
||||
|
||||
int fs_OpenDir(fs_char *fs_path, fs_romfs_char *path, u32 pathlen, fs_dir *dir);
|
||||
void fs_PrintDir(fs_dir *dir, u32 depth);
|
||||
|
||||
+5
-5
@@ -329,9 +329,9 @@ u32 GetDirUTableIndex(romfs_buildctx *ctx, fs_dir *dir)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AddDirHashKey(romfs_buildctx *ctx,u32 parent,wchar_t * path,u32 dirOffset)
|
||||
void AddDirHashKey(romfs_buildctx *ctx, u32 parent, fs_romfs_char* path, u32 dirOffset)
|
||||
{
|
||||
u32 hash = CalcPathHash(parent,path,0,wcslen(path));
|
||||
u32 hash = CalcPathHash(parent,path,0,fs_u16StrLen(path));
|
||||
u32 index = hash % ctx->m_dirUTableEntry;
|
||||
if(ctx->dirUTable[index] == 0xffffffff) ctx->dirUTable[index] = dirOffset;
|
||||
else
|
||||
@@ -352,9 +352,9 @@ void AddDirHashKey(romfs_buildctx *ctx,u32 parent,wchar_t * path,u32 dirOffset)
|
||||
}
|
||||
}
|
||||
|
||||
void AddFileHashKey(romfs_buildctx *ctx,u32 parent,wchar_t * path,u32 fileOffset)
|
||||
void AddFileHashKey(romfs_buildctx *ctx,u32 parent, fs_romfs_char *path, u32 fileOffset)
|
||||
{
|
||||
u32 hash = CalcPathHash(parent,path,0,wcslen(path));
|
||||
u32 hash = CalcPathHash(parent,path,0,fs_u16StrLen(path));
|
||||
u32 index = hash % ctx->m_fileUTableEntry;
|
||||
if(ctx->fileUTable[index] == 0xffffffff) ctx->fileUTable[index] = fileOffset;
|
||||
else
|
||||
@@ -532,7 +532,7 @@ void GenIvfcHashTree(romfs_buildctx *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
u32 CalcPathHash(u32 parent,wchar_t * path,u32 start,u32 length)
|
||||
u32 CalcPathHash(u32 parent, fs_romfs_char * path, u32 start, u32 length)
|
||||
{
|
||||
u32 hash = parent ^ 123456789;
|
||||
u32 index = 0;
|
||||
|
||||
Reference in New Issue
Block a user