FileTools
Index
Variables
constmntdir
Defines path to mounted devices directory (e.g. /mnt).
constmoddir
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/).
constroot
Defines external user directory path with trailing slash (e.g. /sdcard/, /storage/emulated/0/).
Functions
GetListOfDirs
Lists children directories for the specified path.
Parameters
path: string
home-relative or absolute path to the file
Returns java.io.File[]
JArray of java.io.File instances of listed directories.
GetListOfFiles
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.
ReadBytesAsset
ReadImage
Reads high-resolution (as-is) bitmap from file.
Parameters
file: string
home-relative or absolute path to the file
Returns Nullable<android.graphics.Bitmap>
object of the bitmap that was read from file or null if file does not exist or is not accessible.
ReadImageAsset
Reads high-resolution (as-is) bitmap from asset by it's full name.
Parameters
name: string
asset name
Returns Nullable<android.graphics.Bitmap>
Object of the bitmap that was read from asset or null, if asset doesn't exist.
ReadJSON
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.
ReadKeyValueFile
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 {}
Object containing
<key>:<value>
pairs from file.[key string]: string
ReadText
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.
ReadTextAsset
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.
WriteImage
Writes bitmap to PNG (lossless and transparent extension) file.
Parameters
file: string
home-relative or absolute path to the file
bitmap: Bitmap
android.graphics.Bitmap to be written to the file
Returns void
WriteJSON
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
WriteKeyValueFile
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
WriteText
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
getFullPath
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.
isExists
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
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
mkworkdirs
- internal
Creates Core Engine working directories.
Returns void
Module that provides methods to work with file system.