fs
local fs = require("@std/fs")fs.close
Closes file, flushing any pending writes.
(file: File) -> ()fs.copy
Copies the file at src to dest.
(src: Pathlike, dest: Pathlike) -> ()fs.createDirectory
Creates a directory at path. If options.makeParents is true, creates any missing parent directories as well.
(path: Pathlike, options: CreateDirectoryOptions?) -> ()fs.exists
Returns true if a file or directory exists at path.
(path: Pathlike) -> booleanfs.link
Creates a hard link at dest pointing to src.
(src: Pathlike, dest: Pathlike) -> ()fs.listDirectory
Returns an array of DirectoryEntry values for the immediate children of the directory at path.
(path: Pathlike) -> { DirectoryEntry }fs.metadata
Returns metadata for the file or directory at path.
(path: Pathlike) -> FileMetadatafs.open
Opens the file at path in the given mode (defaults to "r"). Returns a file handle.
(path: Pathlike, mode: HandleMode?) -> Filefs.read
Reads the full contents of file and returns them as a string.
(file: File) -> stringfs.readFileToString
Returns the entire contents of the file at filepath as a string.
(filepath: Pathlike) -> stringfs.remove
Removes the file at path.
(path: Pathlike) -> ()fs.removeDirectory
Removes the directory at path. If options.recursive is true, removes all contents first.
(path: Pathlike, options: RemoveDirectoryOptions?) -> ()fs.symbolicLink
Creates a symbolic link at dest pointing to src.
(src: Pathlike, dest: Pathlike) -> ()fs.type
Returns the FileType of the entry at path (e.g. "file", "dir", "symlink").
(path: Pathlike) -> FileTypefs.walk
Returns an iterator over all paths under path. If options.recursive is true, descends into subdirectories.
See example/walk_directory.luau for usage.
(path: Pathlike, options: WalkOptions?) -> () -> Path?fs.watch
Watches path for filesystem changes. Returns a Watcher with a next method that returns the next
WatchEvent, or nil if none is available, and a close method to stop watching.
Note: a while loop must be used rather than a for loop. See example/watch_directory.luau for usage.
(path: Pathlike) -> Watcherfs.write
Writes contents to file.
(file: File, contents: string) -> ()fs.writeStringToFile
Writes contents to the file at filepath, replacing any existing contents.
(filepath: Pathlike, contents: string) -> ()