4public sealed class NdsFile
7 private readonly IImageDataSource _source;
17 IImageDataSource source,
33 public int Id {
get; }
39 public string Name {
get; }
58 public async ValueTask
CopyToAsync(Stream destination, CancellationToken cancellationToken =
default)
60 ArgumentNullException.ThrowIfNull(destination);
61 if (!destination.CanWrite)
63 throw new ArgumentException(
"The NitroFS file destination must be writable.", nameof(destination));
67 await source.CopyToAsync(destination, cancellationToken).ConfigureAwait(
false);
73 public async ValueTask<byte[]>
ReadAllBytesAsync(CancellationToken cancellationToken =
default)
75 if (
Data.Length > Array.MaxLength)
77 throw new IOException($
"NitroFS file {FullPath} is too large to materialize as a byte array.");
80 byte[] data =
new byte[
Data.Length];
81 await _source.ReadExactlyAsync(
Data.Offset, data, cancellationToken).ConfigureAwait(
false);
Materializes one FNT directory record as a navigable node while preserving its encoded child order.
string FullPath
Identifies the entry with ordinal, slash-delimited semantics such as /data/maps/map....
NdsRegion Data
Locates the uncompressed payload through the FAT's half-open start/end offsets.
async ValueTask CopyToAsync(Stream destination, CancellationToken cancellationToken=default)
Streams this allocation into a caller-owned destination without buffering the complete file in memory...
int Id
Indexes the FAT allocation and is also the identifier referenced by overlay table entries.
Stream OpenRead()
Opens a bounded, seekable stream over the file contents.
async ValueTask< byte[]> ReadAllBytesAsync(CancellationToken cancellationToken=default)
Reads all file contents into memory.
NdsDirectory Parent
Links back to the directory that assigned this file's name and starting file ID.
string Name
Projects each case-sensitive FNT name byte directly to the same-valued Unicode code point....
Identifies a bounded range of bytes in an image.