Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace FileTools

Module that provides methods to work with android file system

Index

Variables

Const mntdir

mntdir: string

Defines path to android /mnt direcory

Const moddir

moddir: string

Defines mods folder path, ends with "/"

Const root

root: string

Defines user directory path, ends with "/"

Functions

GetListOfDirs

  • GetListOfDirs(path: string): File[]
  • Lists children directories for the specified path

    Parameters

    • path: string

      home-relative or absolute path to the file

    Returns File[]

    array of java.io.File instances of listed directories

GetListOfFiles

  • GetListOfFiles(path: string, ext: string): File[]
  • Lists files in the specified directory

    Parameters

    • path: string

      path to directory to look for files in

    • ext: string

      extension of the files to include to the output. Use empty string to include all files

    Returns File[]

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

ReadBytesAsset

  • ReadBytesAsset(name: string): Array<jbyte>
  • Reads bytes array from assets

    Parameters

    • name: string

      asset name

    Returns Array<jbyte>

    java array of bytes read from assets or null if asset doesn't exist

ReadImage

  • ReadImage(file: string): Nullable<Bitmap>
  • Reads bitmap from file

    Parameters

    • file: string

      home-relative or absolute path to the file

    Returns Nullable<Bitmap>

    android.graphics.Bitmap object of the bitmup that was read from file or null if file does not exist or is not accessible

ReadImageAsset

  • ReadImageAsset(name: string): Nullable<Bitmap>
  • Reads bitmap from asset by its full name

    Parameters

    • name: string

      asset name

    Returns Nullable<Bitmap>

    android.graphics.Bitmap object of the bitmup that was read from asset or null, if asset doesn't exist

ReadJSON

  • ReadJSON(dir: string): any
  • Reads file as JSON

    Parameters

    • dir: string

      home-relative or absolute path to the file

    Returns any

    value read from JSON file

ReadKeyValueFile

  • ReadKeyValueFile(dir: string, specialSeparator?: string): object
  • Reads file as key:value pairs

    Parameters

    • dir: string

      home-relative or absolute path to the file

    • Optional specialSeparator: string

      separator between key and value, ":" by default

    Returns object

    object containing key:value pairs from file

ReadText

  • Reads text from file

    Parameters

    • file: any

      home-relative or absolute path to the file

    Returns Nullable<string>

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

ReadTextAsset

  • ReadTextAsset(name: string): string
  • Reads string from asset by its full name

    Parameters

    • name: string

      asset name

    Returns string

    asset contents or null if asset doesn't exist

WriteImage

  • WriteImage(file: string, bitmap: Bitmap): void
  • Writes bitmap to png file

    Parameters

    • file: string

      home-relative or absolute path to the file

    • bitmap: Bitmap

      android.graphics.Bitmap object of the bitmup to be wriiten to the file

    Returns void

WriteJSON

  • WriteJSON(dir: string, obj: any, beautify: boolean): void
  • Writes object to file as JSON

    Parameters

    • dir: string

      home-relative or absolute path to the file

    • obj: any

      object to be written to the file as JSON

    • beautify: boolean

      if true, output JSON is beautified

    Returns void

WriteKeyValueFile

  • WriteKeyValueFile(dir: string, data: object, specialSeparator: string): 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

    • specialSeparator: string

      separator between key and value, ":" by default

    Returns void

WriteText

  • WriteText(file: string, text: string, add?: boolean): 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

    • Optional add: boolean

      if true, appends text to the file, overrides it otherwise. Default value is false

    Returns void

getFullPath

  • getFullPath(path: string): string
  • Converts home-relative path to absolute

    Parameters

    • path: string

      input path

    Returns string

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

isExists

  • isExists(path: string): boolean
  • 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

mkdir

  • mkdir(dir: string): void
  • Creates directory by its 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

mkworkdirs

  • mkworkdirs(): void
  • Creates CoreEngine working directories. Called by CoreEngine and should not be called by end user

    Returns void

Generated using TypeDoc