diff --git a/lib/libnx/include/nx/romfs.h b/lib/libnx/include/nx/romfs.h index 21e2aeb..62fe0ec 100644 --- a/lib/libnx/include/nx/romfs.h +++ b/lib/libnx/include/nx/romfs.h @@ -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) } diff --git a/programs/nstool/source/RomfsProcess.cpp b/programs/nstool/source/RomfsProcess.cpp index 1a0f8a3..115f2ce 100644 --- a/programs/nstool/source/RomfsProcess.cpp +++ b/programs/nstool/source/RomfsProcess.cpp @@ -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();