File

From MiniScript Wiki
Jump to navigation Jump to search

The file module provides access to disk files in both Mini Micro and command-line MiniScript.


Methods and Properties

The following table shows methods available in both Mini Micro and command-line MiniScript.

Method or Property Purpose
file.curdir get the current working directory path
file.setdir path set the current working directory
file.makedir path create a new directory
file.children [path] get all file/subdirectory names of the given/current directory
file.name path get just the file name from a file path
file.parent path get the parent directory of a given path
file.exists path return 1 if a file or directory exists, 0 if not
file.info path get a map of details about a given file or directory
file.child basePath, subpath get a path to a file within a directory
file.delete path delete a file or (empty) directory
file.move oldPath, newPath move/rename a file or directory
file.copy oldPath, newPath copy a file to a new location
file.readLines path read whole content of file as a list of strings
file.writeLines path, lines write a list of strings to a text file, separated by line breaks

The following table shows methods available only in Mini Micro.

Method or Property Purpose
file.export path export a file to the host file system
file.import path import a file from the host file system
file.loadImage path load an Image from a PNG, JPEG, or TGA file
file.saveImage path, image, [quality=80] save an Image to a file
file.loadSound path load a Sound from a WAV or OGG file
file.loadRaw path load binary data as a RawData object
file.saveRaw path, rawData save a RawData object to a file