[nx|nstool] Changed Romfs FileNode and DirNode to not include an empty name[] variable.

This commit is contained in:
jakcron 2018-05-26 11:26:56 +08:00
parent 93509fac5a
commit 8b37665be6
2 changed files with 6 additions and 4 deletions

View file

@ -42,7 +42,8 @@ namespace nx
le_uint32_t file;
le_uint32_t hash;
le_uint32_t name_size;
char name[];
char* name() { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
};
struct sRomfsFileEntry
@ -53,7 +54,8 @@ namespace nx
le_uint64_t size;
le_uint32_t hash;
le_uint32_t name_size;
char name[];
char* name() { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
};
#pragma pack(pop)
}

View file

@ -166,7 +166,7 @@ void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir)
printf(" name=%s\n", f_node->name);
*/
dir.file_list.addElement({std::string(f_node->name, f_node->name_size.get()), mHdr.data_offset.get() + f_node->offset.get(), f_node->size.get()});
dir.file_list.addElement({std::string(f_node->name(), f_node->name_size.get()), mHdr.data_offset.get() + f_node->offset.get(), f_node->size.get()});
file_addr = f_node->sibling.get();
mFileNum++;
@ -176,7 +176,7 @@ void RomfsProcess::importDirectory(uint32_t dir_offset, sDirectory& dir)
{
nx::sRomfsDirEntry* c_node = get_dir_node(child_addr);
dir.dir_list.addElement({std::string(c_node->name, c_node->name_size.get())});
dir.dir_list.addElement({std::string(c_node->name(), c_node->name_size.get())});
importDirectory(child_addr, dir.dir_list.atBack());
child_addr = c_node->sibling.get();