Skip to content

Tables

disk

This table gives access to the disks

Functions

  • list() Returns index table of connected drives
  • get_info(index) Returns table, containing drive information Table keys:
    • size - Drive size, bytes
    • used_space - Used space, bytes
    • used_space_precentage - Used space, percentages
    • name - Drive name

Examples

1
2
3
4
5
6
Include("system_io")

for _, id in pairs(disk.list()) do
    local info = disk.get_info(id)
    console.println(string.format("%d:%s (%i / %i) %f%%", id, info["name"], info["used_space"], info["size"], info["used_space_precentage"] * 100))
end

file

This table gives access to the files

Methods

  • exists(disk_id, path Returns boolean
  • read_bytes(disk_id, path) Returns byte table
  • write_bytes(disk_id, path, table_of_bytes)
  • read_text(disk_id, path) Returns string
  • write_text(disk_id, path, text)
  • read_lines(disk_id, path) Returns string table
  • write_lines(disk_id, path, table_of_strings)
  • delete(disk_id, path)
  • create(disk_id, path) Returns file meta table
  • get_meta(disk_id, path) Returns file meta table
  • move(disk_od, path, target_path)
  • copy(disk_od, path, target_path)

file meta table keys

  • path - Absolute file path
  • size - File size, bytes
  • modified - Date and time of the last modification in UNIX (seconds)
  • created - Date and time of the file creation in UNIX (seconds)
  • owner - File owner

directory

This table gives access to the directories

Methods

  • exists(disk_id, path) Returns boolean
  • create(disk_id, path) Returns directory meta table
  • get_meta(disk_id, path) Returns directory meta table
  • delete(disk_id, path)
  • move(disk_od, path, target_path)
  • copy(disk_od, path, target_path)
  • get_files(disk_id, path) Returns string table
  • get_directories(disk_id, path) Returns string table

directory meta table keys

  • path - Absolute file path
  • modified - Date and time of the last modification in UNIX (seconds)
  • created - Date and time of the file creation in UNIX (seconds)
  • owner - File owner

Global functions

  • Get_file_name(path) - Returns file name with the extension
  • Get_directory_name(path) - Returns directory name
  • Combine_paths(table of paths) - Combines the paths into one
  • Get_parent_directory(path) - Returns parent directory