fs

The FS API allows you to manipulate files and the filesystem.

isDriveRoot(path)Returns true if a path is mounted to the parent filesystem.
complete(sPath, sLocation, bIncludeFiles, bIncludeDirs)
list(path)
combine(pathA, pathB)
getName(path)
getDir(path)
getSize(path)
exists(path)
isDir(path)
isReadOnly(path)
makeDir(path)
move(path, dest)
copy(path, dest)
delete(path)
open(path, mode)
getDrive(path)
getFreeSpace(path)
find(path)
getCapacity(path)Returns true if a path is mounted to the parent filesystem.
attributes(path)Get attributes about a specific file or folder.
isDriveRoot(path)Source

Returns true if a path is mounted to the parent filesystem.

The root filesystem "/" is considered a mount, along with disk folders and the rom folder. Other programs (such as network shares) can exstend this to make other mount types by correctly assigning their return value for getDrive.

Parameters

  1. path string The path to check.

Returns

  1. boolean If the path is mounted, rather than a normal file/folder.

Throws

  • If the path does not exist.

See also

complete(sPath, sLocation, bIncludeFiles, bIncludeDirs)Source

Parameters

  1. sPath
  2. sLocation
  3. bIncludeFiles
  4. bIncludeDirs
list(path)Source

Parameters

  1. path string

Returns

  1. { string... }
combine(pathA, pathB)Source

Parameters

  1. pathA string
  2. pathB string

Returns

  1. string
getName(path)Source

Parameters

  1. path string

Returns

  1. string
getDir(path)Source

Parameters

  1. path string

Returns

  1. string
getSize(path)Source

Parameters

  1. path string

Returns

  1. number
exists(path)Source

Parameters

  1. path string

Returns

  1. boolean
isDir(path)Source

Parameters

  1. path string

Returns

  1. boolean
isReadOnly(path)Source

Parameters

  1. path string

Returns

  1. boolean
makeDir(path)Source

Parameters

  1. path string
move(path, dest)Source

Parameters

  1. path string
  2. dest string
copy(path, dest)Source

Parameters

  1. path string
  2. dest string
delete(path)Source

Parameters

  1. path string
open(path, mode)Source

Parameters

  1. path string
  2. mode string

Returns

  1. any...
getDrive(path)Source

Parameters

  1. path string

Returns

  1. any...
getFreeSpace(path)Source

Parameters

  1. path string

Returns

  1. any
find(path)Source

Parameters

  1. path string

Returns

  1. { string... }
getCapacity(path)Source

Returns true if a path is mounted to the parent filesystem.

The root filesystem "/" is considered a mount, along with disk folders and the rom folder. Other programs (such as network shares) can extend this to make other mount types by correctly assigning their return value for getDrive.

Parameters

  1. path string The path of the drive to get.

Returns

  1. number | nil This drive's capacity. This will be nil for "read-only" drives, such as the ROM or treasure disks.

Throws

  • If the capacity cannot be determined.

attributes(path)Source

Get attributes about a specific file or folder.

The returned attributes table contains information about the size of the file, whether it is a directory, and when it was created and last modified.

The creation and modification times are given as the number of milliseconds since the UNIX epoch. This may be given to os.date in order to convert it to more usable form.

Parameters

  1. path string The path to get attributes for.

Returns

  1. { size = number, isDir = boolean, created = number, modified = number } The resulting attributes.

Throws

  • If the path does not exist.

See also

  • getSize If you only care about the file's size.
  • isDir If you only care whether a path is a directory or not.

Types

ReadHandle

A file handle which can be read from.

See also

ReadHandle.read(count)Source

Parameters

  1. count
ReadHandle.readAll()Source
ReadHandle.readLine(with_trailing)Source

Parameters

  1. with_trailing
ReadHandle.seek(whence, offset)Source

Parameters

  1. whence
  2. offset
ReadHandle.close()Source

WriteHandle

A file handle which can be written to.

See also

WriteHandle.write(text)Source

Parameters

  1. text
WriteHandle.writeLine(text)Source

Parameters

  1. text
WriteHandle.flush(text)Source

Parameters

  1. text
WriteHandle.seek(whence, offset)Source

Parameters

  1. whence
  2. offset
WriteHandle.close()Source