# NandFiler

## Overview

The `NandFiler` tool manipulates data in the system memory (NAND). You can use it to delete, browse, and edit photo data, as well as the save data of the NAND application stored in Wii system memory. By using an SD Card, you can also use this tool to import and export save data.

## Execution

Run it in the following ways.

- Using the IS-TWL-DEBUGGER software to run `NandFiler.srl`
- Using the IS-TWL-DEBUGGER software to import and then run `NandFiler.tad`
- Writing `NandFiler.srl` to a DS Game Card and then running it
- Using TWL Nmenu to import and then run `NandFiler.tad`

If you are running the TWL Nmenu using the IS-TWL-DEBUGGER software, a "Please wait a moment" dialog box appears, and you will no longer be able to perform operations in the IS-TWL-DEBUGGER software. To exit, click Force Quit in the dialog box.

## Mode

There are three modes in NandFiler.

- Filer mode: Lets you traverse directories and check file sizes, timestamps, and attributes
- View mode: Lets you browse file contents
- Edit mode: Lets you edit file contents

## Filer Mode

The `NandFiler` tool starts in Filer mode by default.
In Filer mode, after you select either photo data, NAND application save data that has been already imported in the system, or SD Card data, you can browse and operate on that directory tree.
When you are browsing the contents of an SD Card, file and directory names will not appear if they use characters that cannot be converted to Shift_JIS.
The following table shows what operations you can perform.

Button | Operation
--- | ---
SELECT | Displays a list of operations
←→ | Switches pages for the displayed items.
↑↓ | Selects files and so on.
A | Confirms an item.
B | Cancels the selected archive or file. Moves to the parent directory.
X | Opens a submenu when a file or archive is selected.

### Title Selection

This is the state immediately after startup. The left side of the screen displays links to the Game Code of the installed NAND application (blue), and to photo data and the SD Card (purple).
Selecting a Game Code switches to archive selection in the center of the screen. Selecting a link to photo data or an SD Card switches to file selection on the right side of the screen. The following operations can be selected on the submenu displayed by pressing the X Button.

- Export ... Export data
- Fill ... Fill the photo region

#### Export

Copies files from the application's save data region or the PHOTO directory to the SD Card.
A directory is created on the SD Card (named either [`4-digit game code_4-digit version`] or [`PHOTO`]), and then the data is copied there.

#### Fill

Writes photo data to the PHOTO directory, leaving the photo region with zero available memory.
The photo data written using this process cannot be viewed with the Nintendo DSi Camera.
This process may take 30 seconds or more to complete.

### Archive Selection

Selecting a Game Code under Title Selection moves here. For Archive Selection, you can choose `Public`, `Private`, or `SBanner`. These are links to the public save data, private save data, and sub-banner of the NAND application selected under Title Selection.
The following operations can be selected on the submenu displayed by pressing the X Button.

- Backup: Backs up save data
- Break: Destroys the save data region
- Format: Formats the save data region or sub-banner

However, the Backup and Break features do not exist in the sub-banner submenu.

#### Backup

Backs up save data on the SD card. The data backed up here can be imported using the `Restore` operation, described below.
`Backup` differs from the `Export` operation described above in that the entire file system of the save data region is copied to the SD card, but with Export, data is copied in file units.

#### Break

Destroys the FAT system region of the save data. Use this for debugging an assumed problem with the save data region causing `FS_RESULT_BAD_FORMAT` to occur.
This tool can restore the destroyed save data region through any of the methods described below.

- Execute Backup before using Break and then use Restore after Break
- Run Format (files in the save data are deleted)
- Reimport the application in question on the TWL Nmenu
- Re-import using the IS-TWL-DEBUGGER software: Select File → Load File → TAD and the Control imports option

To restore while the application is running, use `NA_FormatTitleArchive`.

#### Format

Initializes the save data and sub-banner. Restoration is possible if save data or sub-banner data becomes invalid using a break.

### File Selection

If PHOTO or SD have been selected under Title Selection, selecting any save data under Archive Selection moves to here.
A list of directories (yellow) and files (white) are displayed under File Selection.
When a directory is selected, press the A Button to browse the contents of that directory. When a file is selected, press the A Button to switch to View mode.
Following is the meaning of the information that is displayed at the top of the screen in File Selection.

Size | File size.
CTime | The time the file was created.
MTime | The time the file was last modified.
ATime | The time the file was last accessed.
Attr | File attributes REA: Read-only files HID: Hidden files SYS: System files VOL: Volume level PRO: Protected files ARC: Archives
Very bottom of screen | Full path to the selected file.

The following operations can be selected on the submenu displayed by pressing the X Button.

- Import: Imports Save Data
- Delete: Deletes files and directories
- Restore: Restores save data

#### Import

This operation is valid for directories created with the `Export` operation. Note, however, that exported PHOTO directories cannot be imported.
This operation copies data to the save data region of system memory. Provided the data does not exceed the size of the save data region of system memory, the data copied over by `Export` can be imported even if they have been altered.

#### Delete

Deletes a file or directory. If a directory is selected, files and directories inside the directory are deleted recursively.

#### Restore

This operation is only valid for save data backup files created using the Backup feature. The backup file on the SD card is imported to system NAND memory.
Note that importing backup files will fail in the cases given below.

- When the backup file has been modified
- When the backup file name has been changed
- When the corresponding application has been deleted
- When the save data save size of the application in question has changed

## View Mode

In View mode, you can view file contents. The displayed filename and addresses are shown on the upper screen.
The content of the file (binary values and corresponding characters) is shown on the lower screen.

The following specifications apply to the display of characters.

- `0x00` can be replaced by `0x20` (by a space)
- `0x20` to `0x7A` conform to ASCII code
- Other regions display hiragana and katakana (font incorporated as sample)

The following table shows what operations you can perform.

Button | Operation
--- | ---
←→ | Scrolls one page at a time.
↑↓ | Scrolls (one line at a time).
A | Switches to Edit mode.
B | Switches to `Filer` mode. If file has been edited in Edit mode, it will be saved.

## Edit Mode

Edit mode lets you edit files.
Take note of the following restrictions.

#### Editing restrictions

- There is no support for changes in file size.
- When the file being edited is larger than 14M, if regions near the start and the end of the file are edited at the same time, earlier changes will not be reflected.

### Non-Editing State

This state occurs when entering Edit mode.

Button | Operation
--- | ---
←→↑↓ | Moves the cursor
A | Switches to the editing state
B | Switches to View mode

### Editing State

Button | Operation
--- | ---
←→↑↓ | Moves the cursor
B | Switches to the non-editing state
L, R | Increase, Decrease value

Pressing the L or R Buttons in the editing state will change the value at the current cursor position.
Locations where any edits have been made will appear in green. The cursor can be moved freely even in the editing state, but the horizontal range of movement is reduced compared to the non-editing state.
To save edits, select Yes from the choices displayed when you press the B Button in View mode.

## Location

`$TwlSDK/bin/ARM9-TS/Rom/NandFiler.srl
$TwlSDK/bin/ARM9-TS/Rom/NandFiler.tad`

## See Also

## Revision History

2009/12/25 Added photo region fill feature.
2009/11/30 Removed the `Delete` and `Size0` features from Archive Selection. There is no longer any need to support these errors.
2009/05/20 Noted that non-Shift_JIS filenames on an SD Card are not displayed; added sub-banners to Archive Selection; and added the `Delete`, `Size0`, and `Format` features.
2009/02/18 Added text related to the `Break` feature and `FS_RESULT_BAD_FORMAT`.
2008/01/13 Added text for the `Import` and `Export` features.
2008/12/08 Mentioned restrictions when editing.
2008/11/26 Complied with added screenshots and changes to operations.
2008/10/21 Added text for the `Backup` and `Restore` features.
2008/09/16 Added text for the `Break` feature.
2008/07/18 In Location, changed "Release" to "Rom."
2008/07/14 Changed terminology.
2008/07/07 Initial version.

CONFIDENTIAL