Skip to content

fs

luau
local fs = require("@std/fs")

fs.close

luau
(file: file) -> ()

fs.copy

luau
(src: pathlike, dest: pathlike) -> ()

fs.createdirectory

luau
(path: pathlike, options: createdirectoryoptions?) -> ()

fs.exists

luau
(path: pathlike) -> boolean
luau
(src: pathlike, dest: pathlike) -> ()

fs.listdirectory

luau
(path: pathlike) -> { directoryentry }

fs.metadata

luau
(path: pathlike) -> metadata

fs.open

luau
(path: pathlike, mode: handlemode?) -> file

fs.read

luau
(file: file) -> string

fs.readfiletostring

luau
(filepath: pathlike) -> string

fs.remove

luau
(path: pathlike) -> ()

fs.removedirectory

luau
(path: pathlike, options: removedirectoryoptions?) -> ()
luau
(src: pathlike, dest: pathlike) -> ()

fs.type

luau
(path: pathlike) -> type

fs.walk

Note: for loops do not support yielding generalized iterators, so we cannot use fs.walk as for path in fs.walk(...) do directly. A while loop can be used instead. See example/walk_directory.luau for usage.

luau
(path: pathlike, options: walkoptions?) -> () -> path?

fs.watch

Iterator function that yields filename and event pairs when changes occur in the watched path.

Also provides a close method to stop watching.

Note: for loops do not support yielding generalized iterators, so we cannot use fs.watch as for _ in fs.watch(...) do directly. A while loop can be used instead. See example/watch_directory.luau for usage.

luau
(path: pathlike) -> watcher

fs.write

luau
(file: file, contents: string) -> ()

fs.writestringtofile

luau
(filepath: pathlike, contents: string) -> ()