Changes

1,018 bytes added ,  03:05, 31 March 2019
Core file system
Line 702: Line 702:  
|}
 
|}
   −
=== Directory Table Entry ===
+
=== Save File Table ===
   −
* Index 0 is the start of a linked list that contains all invalid/inactive directories.
+
The save file table is similar to the RomFS file table, except the save file table uses linked lists instead of dictionaries.
* Index 1 is the start of a linked list that contains all valid/active directories.
+
 
* Index 2 is the root directory.
+
The table contains a list of directory entries and a list of file entries. Their respective types are:<br />
 +
'''SaveFsList<SaveFileTableEntry<SaveDirectoryInfo>>'''<br />
 +
'''SaveFsList<SaveFileTableEntry<SaveFileInfo>>'''
 +
 
 +
==== Save File Table Entry ====
 +
 
 +
SaveFileTableEntry<class T>
    
{| class="wikitable"
 
{| class="wikitable"
Line 716: Line 722:  
| 0x00
 
| 0x00
 
| 4
 
| 4
| Parent directory node index
+
| Next entry index. A value of 0 indicates the end of the list.
 
|-
 
|-
 
| 0x04
 
| 0x04
| 64
+
| sizeof(T)
| Filename
+
| Value of type T.
 +
|-
 +
|}
 +
 
 +
==== Save File Info ====
 +
 
 +
Holds the information of a single file.
 +
 
 +
{| class="wikitable"
 
|-
 
|-
| 0x44
+
! Start
| 4
+
! Length
| Next sibling directory node index
+
! Description
 
|-
 
|-
| 0x48
+
| 0x00
 
| 4
 
| 4
| First child directory node index
+
| Starting block index.
 
|-
 
|-
| 0x4c
+
| 0x04
 
| 8
 
| 8
| First child file node index
+
| File length in bytes.
 
|-
 
|-
| 0x54
+
| 0x0C
 
| 8
 
| 8
| Unused?
+
| Reserved.
 +
|-
 +
|}
 +
 
 +
==== Save Directory Info ====
 +
 
 +
Holds the information of a single directory.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Start
 +
! Length
 +
! Description
 +
|-
 +
| 0x00
 +
| 4
 +
| First child directory index. 0 if none.
 
|-
 
|-
| 0x5c
+
| 0x04
 
| 4
 
| 4
| Next directory node index in the chain of invalid or valid directories. If this is the first block in a list of length 0, this value will contain the total number of directory nodes.
+
| First child file index. 0 if none.
 +
|-
 +
| 0x08
 +
| 0xC
 +
| Reserved.
 
|-
 
|-
 
|}
 
|}
   −
=== File Table Entry ===
+
=== Save FS List ===
   −
* Index 0 is the start of a linked list that contains all invalid/inactive files.
+
SaveFsList<class T>
* Index 1 is the start of a linked list that contains all valid/active files.
+
 
 +
This is a linked list that is used internally by '''Save File Table''' as a key-value store. Integer/string pairs are used as keys. The list is represented as a single array so that it can be easily stored and read from a file. Entry indexes 0 and 1 are reserved.
 +
 
 +
Index 0 is the start of a list containing all free entries. When an item in the list is removed, the entry it was using is added to this list for future reuse.
 +
 
 +
Index 1 is the start of a list containing all currently used entries.
 +
 
 +
The first 8 bytes of the list are used as follows. Indexes 0 and 1 are included in these counts.
    
{| class="wikitable"
 
{| class="wikitable"
Line 757: Line 798:  
| 0x00
 
| 0x00
 
| 4
 
| 4
| Parent directory node index
+
| The size of the list. Freed entries that have not been reused are included in the count.
 
|-
 
|-
 
| 0x04
 
| 0x04
| 64
+
| 4
| Filename
+
| The current capacity of the list based on the number of bytes allocated.
 +
|-
 +
|}
 +
 
 +
==== Save FS List Key ====
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Start
 +
! Length
 +
! Description
 
|-
 
|-
| 0x44
+
| 0x00
 
| 4
 
| 4
| Next sibling file node index
+
| 32-bit integer.
 
|-
 
|-
| 0x48
+
| 0x04
| 4
+
| 0x40
| Index of the block that the file starts at
+
| 0x40-byte string.
 +
|-
 +
|}
 +
 
 +
==== Save FS List Entry ====
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Start
 +
! Length
 +
! Description
 
|-
 
|-
| 0x4c
+
| 0x00
| 8
+
| 0x44
| File size in bytes
+
| Key.
 
|-
 
|-
| 0x54
+
| 0x44
| 8
+
| sizeof(T)
| Unused?
+
| Value.
 
|-
 
|-
| 0x5c
+
| 0x44 + sizeof(T)
 
| 4
 
| 4
| Next file node index in the chain of invalid or valid files. If this is the first block in a list of length 0, this value will contain the total number of file nodes.
+
| Next entry node index. A value of 0 indicates the end of the list.
 
|-
 
|-
 
|}
 
|}
74

edits