makerom: romfs

made fixes by enler platform independent
This commit is contained in:
applestash
2014-09-20 17:29:52 +10:00
parent b4154011a7
commit de12f54762
3 changed files with 14 additions and 8 deletions
+7 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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;