Class representing a Nintendo SARC (Simple Archive) file. Allows parsing existing archives, adding/removing files, and compiling new SARC archives.

Constructors

  • Creates a new empty SarcFile.

    Parameters

    • isLittleEndian: boolean = false

      Specifies if the SARC file should be compiled/written in Little Endian. Defaults to false (Big Endian, standard for Wii U/Switch).

    Returns SarcFile

Methods

  • Adds an existing FileEntry object to the SARC.

    Parameters

    Returns void

  • Helper to add a raw file directly by specifying its data and destination path.

    Parameters

    • data: Bytes

      The file data (ArrayBuffer or Uint8Array).

    • destinationFilePath: string

      The relative path/filename inside the archive.

    Returns void

  • Retrieves the array of all file entries currently in this SARC.

    Returns FileEntry[]

    An array of FileEntry references.

  • Returns true if the archive is read/written in Little Endian byte order.

    Returns boolean

    True if Little Endian, false if Big Endian.

  • Parses and loads a SARC archive from binary data. Supports both uncompressed SARC files and Yaz0-compressed archives.

    Parameters

    • input: Bytes

      The binary source data (ArrayBuffer or Uint8Array).

    Returns void

  • Removes a FileEntry from the SARC list.

    Parameters

    • file: FileEntry

      The FileEntry reference to remove.

    Returns void

  • Compiles and builds the SARC archive into a single Uint8Array.

    Parameters

    • compression: number = 0

      The Yaz0 compression level to apply to the output file (0 = no compression, 9 = maximum search depth compression). Defaults to 0.

    Returns Uint8Array<ArrayBufferLike>

    The built SARC archive as a Uint8Array.

  • Sets the default byte alignment for files inside the SARC archive data section. Alignment must be a non-zero power of 2 (e.g. 4, 8, 0x2000).

    Parameters

    • value: number

      The byte alignment value.

    Returns void

  • Sets the multiplier value used during filename string hash calculation. Defaults to 0x65.

    Parameters

    • value: number

      The hash multiplier value.

    Returns void

  • Sets the byte order format (Endianness) for the archive.

    Parameters

    • isLittleEndian: boolean

      True for Little Endian, false for Big Endian.

    Returns void