Line 220: |
Line 220: |
| | Padding | | | Padding |
| |} | | |} |
| + | |
| + | == Directory Entry Table == |
| + | |
| + | The directory entry table is an array of the entry type shown below. It describes the directory hierarchy of the file system. There are two variants of the directory entry type. |
| + | |
| + | === Savegame/Extdata Variant=== |
| + | {| class="wikitable" border="1" |
| + | ! Offset |
| + | ! Length |
| + | ! Description |
| + | |- |
| + | | 0x00 |
| + | | 4 |
| + | | Parent directory index. 0 for root |
| + | |- |
| + | | 0x04 |
| + | | 16 |
| + | | ASCII directory name in. All zero for root |
| + | |- |
| + | | 0x14 |
| + | | 4 |
| + | | Next sibling directory index. 0 if this is the last one |
| + | |- |
| + | | 0x18 |
| + | | 4 |
| + | | First subdirectory index. 0 if not exists |
| + | |- |
| + | | 0x1C |
| + | | 4 |
| + | | First file index in file entry table. 0 for empty directory |
| + | |- |
| + | | 0x20 |
| + | | 4 |
| + | | Padding / zero? |
| + | |- |
| + | | 0x24 |
| + | | 4 |
| + | | Index of the next directory in the same hash table bucket. 0 if this is the last one |
| + | |} |
| + | |
| + | === Title Database Variant=== |
| + | Because title database only has one directory for "root", its directory entry table degenerates into many zeros whose structure is not recognizable. The size of one entry here is guessed. |
| + | {| class="wikitable" border="1" |
| + | ! Offset |
| + | ! Length |
| + | ! Description |
| + | |- |
| + | | 0x00 |
| + | | 4 |
| + | | Parent directory index = 0 for root |
| + | |- |
| + | | 0x04 |
| + | | 4 |
| + | | Next sibling directory index = 0 because this is the last one |
| + | |- |
| + | | 0x08 |
| + | | 4 |
| + | | First subdirectory index = 0 because there is no subdirectory |
| + | |- |
| + | | 0x0C |
| + | | 4 |
| + | | First file index in file entry table. 0 for empty directory |
| + | |- |
| + | | 0x10 |
| + | | 12 |
| + | | Padding / zero? |
| + | |- |
| + | | 0x1C |
| + | | 4 |
| + | | Index of the next directory in the same hash table bucket = 0 because there is no other directory |
| + | |} |
| + | |
| + | === Dummy Entry=== |
| + | There are also some dummy entries in the array |
| + | {| class="wikitable" border="1" |
| + | ! Offset |
| + | ! Length |
| + | ! Description |
| + | |- |
| + | | 0x00 |
| + | | 4 |
| + | | Current Total entry count |
| + | |- |
| + | | 0x04 |
| + | | 4 |
| + | | Maximum entry count = maximum directory count + 2 |
| + | |- |
| + | | 0x08 |
| + | | 28/20 |
| + | | Padding / All zero |
| + | |- |
| + | | 0x24/0x1C |
| + | | 4 |
| + | | Index of the next dummy entry. 0 if this is the last one |
| + | |} |
| + | |
| + | The 0-th entry of the array is always a dummy entry, which functions as the head of the dummy entry linked list. The 1-st entry of the array is always the root. Therefore maximum entry count is two more than maximum directory count. Dummy entries are left there when deleting directories, and reserved for future use. |
| | | |
| == File Allocation Table == | | == File Allocation Table == |