NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsForge.NdsFileSystemBuilder Class Referencesealed

Models structural NitroFS changes before ROM offsets and file identifiers are assigned. More...

Public Member Functions

async ValueTask< NdsDirectoryImportResult > ImportDirectoryAsync (string sourceDirectory, string destinationDirectory="/", NdsDirectoryImportOptions? options=null, CancellationToken cancellationToken=default)
 Stages and transactionally merges a host directory into this NitroFS recipe. Calling the method repeatedly provides ordered multi-root composition under an explicit file-collision policy; a failed stage changes nothing.
NdsBuildFile GetFile (string path)
 Resolves a builder-owned payload so other recipe components can retain its identity across path moves.
NdsFileSystemBuilder CreateDirectory (string path)
 Declares a directory, retaining it even when no descendant files are added.
NdsFileSystemBuilder AddFile (string path, ReadOnlySpan< byte > contents)
 Adds a payload that must not already exist, creating its parent directories as needed.
NdsFileSystemBuilder SetFile (string path, ReadOnlySpan< byte > contents)
 Defines the payload at a path, replacing an existing file while preserving directory validity.
NdsFileSystemBuilder RemoveFile (string path)
 Removes a payload while leaving its parent directories available for later files or empty output.
NdsFileSystemBuilder MoveFile (string sourcePath, string destinationPath)
 Changes a file's NitroFS identity without copying or transforming its payload.
NdsFileSystemBuilder MoveDirectory (string sourcePath, string destinationPath)
 Re-roots an entire directory subtree while preserving every payload byte and relative child path.
NdsFileSystemBuilder RemoveDirectory (string path)
 Omits an explicitly declared directory after proving that no descendants would become orphaned.

Properties

IReadOnlyCollection< string > Directories [get]
 Provides a stable view of every directory that will appear in the FNT, including empty ones.
IReadOnlyCollection< NdsBuildFileFiles [get]
 Provides a path-sorted snapshot of payloads currently destined for the image.

Detailed Description

Models structural NitroFS changes before ROM offsets and file identifiers are assigned.

NitroFS stores names in a directory table but stores payload locations in a separate FAT. This builder deliberately works in paths and bytes so callers can add, remove, move, or rename entries without managing either binary table. BuildSnapshot assigns identifiers in a stable, ordinal order, making repeated builds from the same logical tree reproducible.

Definition at line 13 of file NdsFileSystemBuilder.cs.

Member Function Documentation

◆ AddFile()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.AddFile ( string path,
ReadOnlySpan< byte > contents )
inline

Adds a payload that must not already exist, creating its parent directories as needed.

Parameters
pathAn absolute or root-relative path whose segments must map one-to-one to FNT bytes.
contentsExact uncompressed payload bytes. They are copied before this method returns and may therefore come from stack memory, pooled storage, or a mutable caller buffer.
Returns
The same builder, allowing several tree edits to be chained.
Exceptions
IOExceptionThe path is occupied or a parent component is a file.

Definition at line 108 of file NdsFileSystemBuilder.cs.

◆ CreateDirectory()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.CreateDirectory ( string path)
inline

Declares a directory, retaining it even when no descendant files are added.

Parameters
pathAn absolute or root-relative NitroFS path. Separators are normalized to /; each segment must be 1-127 eight-bit characters and may not be . or ...
Returns
The same builder, allowing several tree edits to be chained.
Exceptions
IOExceptionA file occupies the directory or one of its parent paths.

Definition at line 90 of file NdsFileSystemBuilder.cs.

◆ GetFile()

NdsBuildFile NdsForge.NdsFileSystemBuilder.GetFile ( string path)
inline

Resolves a builder-owned payload so other recipe components can retain its identity across path moves.

Parameters
pathCanonical or root-relative NitroFS file path.
Returns
The stable payload object whose NdsBuildFile.Path follows later move operations.
Exceptions
FileNotFoundExceptionNo file exists at the normalized path.

Definition at line 73 of file NdsFileSystemBuilder.cs.

◆ ImportDirectoryAsync()

async ValueTask< NdsDirectoryImportResult > NdsForge.NdsFileSystemBuilder.ImportDirectoryAsync ( string sourceDirectory,
string destinationDirectory = "/",
NdsDirectoryImportOptions? options = null,
CancellationToken cancellationToken = default )
inline

Stages and transactionally merges a host directory into this NitroFS recipe. Calling the method repeatedly provides ordered multi-root composition under an explicit file-collision policy; a failed stage changes nothing.

Parameters
sourceDirectoryExisting host root read without following links implicitly.
destinationDirectoryNitroFS directory receiving the source root's contents, commonly /.
optionsOptional link, collision, file-count, and total-byte policy.
cancellationTokenCancels host enumeration and file reads before application begins.
Returns
Counts and bytes actually applied, plus policy-skipped entries.

Definition at line 51 of file NdsFileSystemBuilder.cs.

◆ MoveDirectory()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.MoveDirectory ( string sourcePath,
string destinationPath )
inline

Re-roots an entire directory subtree while preserving every payload byte and relative child path.

Parameters
sourcePathAn existing directory other than the immutable NitroFS root.
destinationPathA free path outside the source subtree.
Returns
The same builder; file objects already obtained from Files reflect their rewritten paths.
Exceptions
DirectoryNotFoundExceptionThe source directory does not exist.
IOExceptionThe move would create a cycle or collide with an existing entry.

Definition at line 201 of file NdsFileSystemBuilder.cs.

◆ MoveFile()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.MoveFile ( string sourcePath,
string destinationPath )
inline

Changes a file's NitroFS identity without copying or transforming its payload.

Parameters
sourcePathThe absolute or root-relative path of the existing payload.
destinationPathA free destination whose parent chain contains only directories.
Returns
The same builder; existing references to the moved NdsBuildFile observe its new path.
Exceptions
FileNotFoundExceptionThe source does not identify a file.
IOExceptionThe destination or one of its parent paths is occupied incompatibly.

Definition at line 170 of file NdsFileSystemBuilder.cs.

◆ RemoveDirectory()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.RemoveDirectory ( string path)
inline

Omits an explicitly declared directory after proving that no descendants would become orphaned.

Parameters
pathAn existing non-root directory path.
Returns
The same builder, allowing several tree edits to be chained.
Exceptions
DirectoryNotFoundExceptionThe normalized path is not a directory.
IOExceptionThe directory still contains a file or child directory.

Definition at line 258 of file NdsFileSystemBuilder.cs.

◆ RemoveFile()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.RemoveFile ( string path)
inline

Removes a payload while leaving its parent directories available for later files or empty output.

Parameters
pathThe absolute or root-relative path of the existing file.
Returns
The same builder, allowing several tree edits to be chained.
Exceptions
FileNotFoundExceptionNo file exists at the normalized path.

Definition at line 151 of file NdsFileSystemBuilder.cs.

◆ SetFile()

NdsFileSystemBuilder NdsForge.NdsFileSystemBuilder.SetFile ( string path,
ReadOnlySpan< byte > contents )
inline

Defines the payload at a path, replacing an existing file while preserving directory validity.

Parameters
pathAn absolute or root-relative path whose segments must map one-to-one to FNT bytes.
contentsExact uncompressed bytes, copied immediately into builder-owned memory.
Returns
The same builder, allowing several tree edits to be chained.
Exceptions
IOExceptionThe path names a directory or a parent component is a file.

Definition at line 130 of file NdsFileSystemBuilder.cs.

Property Documentation

◆ Directories

IReadOnlyCollection<string> NdsForge.NdsFileSystemBuilder.Directories
get

Provides a stable view of every directory that will appear in the FNT, including empty ones.

The root is represented as /; all other values are absolute NitroFS paths.

Definition at line 30 of file NdsFileSystemBuilder.cs.

◆ Files

IReadOnlyCollection<NdsBuildFile> NdsForge.NdsFileSystemBuilder.Files
get

Provides a path-sorted snapshot of payloads currently destined for the image.

Enumeration order is useful for deterministic tooling but is not the final FAT identifier order; NitroFS requires files to be grouped by their parent directory during serialization.

Definition at line 39 of file NdsFileSystemBuilder.cs.


The documentation for this class was generated from the following file: