Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SarcFile

Index

Constructors

constructor

  • new SarcFile(isLittleEndian?: boolean): SarcFile
  • Construct a new SARC archive. This library

    • does not support files with duplicate names
    • does not support files without name

    Parameters

    • isLittleEndian: boolean = false

      if true, endian is set to little, if false endian is set to big

    Returns SarcFile

Methods

addFile

  • Add a file to this SARC archive.

    Parameters

    Returns void

addFileFromPath

  • addFileFromPath(filePath: string, destinationFilePath?: string): void
  • Add a file to the SARC archive. In order to 'put' it in a folder, use a custom destinationFilePath

    Parameters

    • filePath: string

      the path to the file you want to add

    • destinationFilePath: string = ""

      e.g. image.jpg, or extra/image.jpg

    Returns void

addFolderContentsFromPath

  • addFolderContentsFromPath(folderPath: string, destinationFolderName?: string): Promise<void>
  • Add all files inside a folder to the SARC archive (recursively). Notes:

    • the contents of this folder are stored in the root of the SARC: the folder itself is not included.
    • empty directories are skipped In order to 'put' the contents in a folder, use a custom destinationFolderPath

    Parameters

    • folderPath: string

      the path to the folder you want to add

    • destinationFolderName: string = ""

      e.g. images, or extra/images

    Returns Promise<void>

addRawFile

  • addRawFile(data: Buffer, destinationFilePath: string): void
  • Add a file to this SARC archive. In order to 'put' it in a folder, use a custom destinationFilePath

    Parameters

    • data: Buffer

      raw file Buffer

    • destinationFilePath: string

      e.g. image.jpg, or extra/image.jpg

    Returns void

extractTo

  • extractTo(destDir: string): void
  • Extract all SARC archive contents to a directory.

    Parameters

    • destDir: string

      the destination directory path

    Returns void

getFiles

getIsLittleEndian

  • getIsLittleEndian(): boolean
  • Return whether the SARC archive is little endian.

    Returns boolean

    true if little, false if big

load

  • load(data: Buffer): void
  • Load and parse a SARC archive. File may be compressed with Yaz0.

    throws

    Error if the SARC archive is invalid or unsupported

    Parameters

    • data: Buffer

      the raw sarc file data Buffer

    Returns void

loadFrom

  • loadFrom(filePath: string): void
  • Load and parse a SARC archive. File may be compressed with Yaz0.

    throws

    Error if the SARC archive is invalid, unsupported, or not found

    Parameters

    • filePath: string

      the sarc file path.

    Returns void

removeFile

  • Remove a specific FileEntry from the contents. Use getFiles() to know which objects are available.

    Parameters

    • file: FileEntry

      the FileEntry object to remove.

    Returns void

save

  • save(compression?: number): Buffer
  • Save current SARC archive to a Buffer.

    Parameters

    • compression: number = 0

      what Yaz0 compression level to use. 0: no compression (fastest), 9: best compression (slowest)

    Returns Buffer

    the output file Buffer

saveTo

  • saveTo(filePath: string, compression?: number): string
  • Save current SARC archive to file.

    Parameters

    • filePath: string

      the save destination. Will use .szs (compressed) or .sarc (uncompressed) if no file extension was provided.

    • compression: number = 0

      what Yaz0 compression level to use. 0: no compression (fastest), 9: best compression (slowest)

    Returns string

    full output file path

setDefaultAlignment

  • setDefaultAlignment(value: number): void
  • Instead of using the default-default alignment of 0x04, use a different value.

    throws

    Error if alignment is not non-zero or not a power of 2

    Parameters

    • value: number

      the new default alignment

    Returns void

setHashMultiplier

  • setHashMultiplier(value: number): void
  • Set the hash multiplier used for filename hashing.

    Parameters

    • value: number

      the new hash multiplier

    Returns void

setLittleEndian

  • setLittleEndian(isLittleEndian: boolean): void
  • Set endian of the SARC archive to little.

    Parameters

    • isLittleEndian: boolean

      if true, endian is set to little, if false endian is set to big

    Returns void

Generated using TypeDoc