Skip to content

fs

The fs module provides an interface for reading and writing to the filesystem.

Filesystem is sandboxed

All filesystem operations are done in a sandboxed directory. See Sandbox.

Summary

Methods

MethodSignatureDescription
read(path: string) -> stringReads the contents of a file as a string.
write(path: string, content: string) -> ()Writes a string to a file.
exists(path: string) -> booleanReturns whether a file or directory exists.
remove(path: string) -> ()Deletes a file or directory.
list(path: string) -> {string}Returns the entries in a directory.
mkdir(path: string, recursive: boolean?) -> ()Creates a directory.
move(from: string, to: string) -> ()Moves or renames a file or directory.
copy(from: string, to: string) -> ()Copies a file to a new location.
metadata(path: string) -> MetadataReturns metadata about a file or directory.
walk(path: string, options: WalkOptions?) -> () -> string?Recursively iterates all files under a directory.
watch(path: string) -> WatcherReturns a push-based watcher with a Signal for change events.