Class FileUtil

Detects the FileFormat of save file (SRA or SRM) based on file size and returns the appropriate SaveFile instance.

Constructors

Methods

  • Swaps bytes in a Uint8Array.

    Parameters

    • input: Uint8Array

      Uint8Array to swap bytes in

    • inPlace: boolean = false

      Determine if the input array should be modified in place (default: false, returns a new Uint8Array)

    Returns Uint8Array

    Swapped bytes Uint8Array

  • Detect the FileFormat based on size SRA: < 0x8000 bytes (32KB) SRM: 0x48800 (contains EEPROM, MemPak, SRAM, FlashRAM sections)

    Parameters

    • file: FsFile

    Returns FileFormat

  • Load a save file from either format and always return the core SRA save

    Parameters

    • path: string

      to load the save file data from, is also used for automatic format detection

    Returns SraSaveFile

  • Writes the savefile to disk in the desired file format

    Parameters

    • path: string

      to write the file to

    • format: FileFormat

      save file format to write

    • save: SraSaveFile

      savefile data to write

    • forceSwap: boolean = false

      force a byte swap before writing (when converting from SRA to SRM the swap will be done automatically, force swapping will reverse the effect in that case)

    Returns void