Namespace FileTools

Module that provides methods to work with file system.

Functions

  • Converts home-relative path to absolute.

    Parameters

    • path: string

      input path

    Returns string

    Same string if input string is an absolute path, an absolute path if input string is a home-relative path.

  • Lists files in the specified directory.

    Parameters

    • path: string

      path to directory to look for files in

    • Optionalext: string

      extension of the files to include to the output

    Returns java.io.File[]

    JArray of java.io.File instances that match specified extension.

  • Verifies if specified home-relative or absolute path exists.

    Parameters

    • path: string

      path to be verified

    Returns boolean

    true, if specified path exists, false otherwise.

  • Creates directory by it's home-relative or absolute path, if one of the parent directories doesn't exist, creates them.

    Parameters

    • dir: string

      path to the new directory

    Returns void

  • Internal

    Creates Core Engine working directories.

    Returns void

  • Reads bytes array from assets.

    Parameters

    • name: string

      asset name

    Returns Nullable<native.Array<jbyte>>

    JArray of bytes read from assets or null if asset doesn't exist.

  • Reads JSON file without comments as object.

    Parameters

    • dir: string

      home-relative or absolute path to the file

    Returns object

    Object represents JSON value read from JSON file.

  • Reads file as <key>:<value> pairs.

    Parameters

    • dir: string

      home-relative or absolute path to the file

    • OptionalspecialSeparator: string

      separator between key and value, ":" by default

    Returns {
        [key: string]: string;
    }

    Object containing <key>:<value> pairs from file.

    • [key: string]: string
  • Reads text as-is from file, append ?.trim() to drop trailing newlines.

    Parameters

    • file: string

      home-relative or absolute path to the file

    Returns Nullable<string>

    File contents or null if file does not exist or not accessible.

  • Reads string from asset by it's full name.

    Parameters

    • name: string

      asset name

    Returns Nullable<string>

    Asset contents or null if asset doesn't exist.

  • Writes bitmap to PNG (lossless and transparent extension) file.

    Parameters

    Returns void

  • Writes object to file as JSON.

    Parameters

    • dir: string

      home-relative or absolute path to the file

    • obj: object

      object to be written to the file as JSON

    • Optionalbeautify: boolean

      if true, output JSON is beautified with tabs

    Returns void

  • Writes <key>:<value> pairs to the file.

    Parameters

    • dir: string

      home-relative or absolute path to the file

    • data: object

      object to be written to the file as a set of key:value pairs

    • OptionalspecialSeparator: string

      separator between key and value, ":" by default

    Returns void

  • Writes text to the file.

    Parameters

    • file: string

      home-relative or absolute path to the file

    • text: string

      text to be written to the file

    • Optionaladd: boolean

      if true, appends text to the file, overrides it otherwise

    Returns void

    add: false
    

Variables

mntdir: string

Defines path to mounted devices directory (e.g. /mnt).

moddir: string

Defines in-pack directory where modders alives with trailing slash (e.g. /storage/emulated/0/games/horizon/packs/Inner_Core_Test/innercore/mods/, /storage/emulated/0/Android/data/com.zheka.horizon/files/games/horizon/packs/Inner_Core_Test/innercore/mods/).

root: string

Defines external user directory path with trailing slash (e.g. /sdcard/, /storage/emulated/0/).

Copyright © 2024 Nernar. Copyright © 2020 #mineprogramming. Built with ❤ and TypeDoc.