From de12f54762bfbef96027db4b17420fcaf1a405fc Mon Sep 17 00:00:00 2001 From: applestash Date: Sat, 20 Sep 2014 17:29:52 +1000 Subject: [PATCH] makerom: romfs made fixes by enler platform independent --- makerom/dir.c | 9 +++++++-- makerom/dir.h | 3 ++- makerom/romfs_gen.c | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/makerom/dir.c b/makerom/dir.c index b0fb1e7..f44a397 100644 --- a/makerom/dir.c +++ b/makerom/dir.c @@ -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; diff --git a/makerom/dir.h b/makerom/dir.h index 6ee72e1..8dcb2c5 100644 --- a/makerom/dir.h +++ b/makerom/dir.h @@ -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); diff --git a/makerom/romfs_gen.c b/makerom/romfs_gen.c index cc5aacc..3d46dc7 100644 --- a/makerom/romfs_gen.c +++ b/makerom/romfs_gen.c @@ -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;