BGE/FileTypes

Alias: BGE.FileTypes


Static Methods

isKnownAssetExtension(extension: string): boolean

static

Whether an extension (e.g. ".png") is a file type the engine's loaders read.

Parameters

  • extension (string) — lowercase, with the dot

Returns

  • boolean

isImageExtension(extension: string): boolean

static

Whether an extension (e.g. ".png") is an image type a bitmap can be loaded from.

Parameters

  • extension (string) — lowercase, with the dot

Returns

  • boolean

forContentType(contentType: string): string

static

The file extension for a Content-Type header (e.g. "image/jpeg; charset=x" -> ".jpg").

Parameters

  • contentType (string)

Returns

  • string — the extension, or "" for a type that isn't a known asset type

sniffExtension(path: string): string

static

Works out a file's type from its first few bytes: images, fonts and sounds.

Parameters

  • path (string) — a local file

Returns

  • string — the extension (e.g. ".png"), or "" if the type isn't recognised

byteText( bytes: roByteArray, start: integer, length: integer, ): string

static

Bytes as text, for comparing file signatures. Stops early at the end of the array; bytes outside printable ASCII become "?".

Parameters

  • bytes (roByteArray)
  • start (integer)
  • length (integer)

Returns

  • string