Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.encodingstd.envstd.fsstd.hashstd.httpstd.netstd.jsonstd.mathstd.parsestd.pathstd.processstd.randomstd.raylibstd.regexstd.stringstd.timestd.url

Read as Markdown

Standard Library

std.fs

Filesystem operations for reading, writing, and managing files and directories.

Exported functions

pub def read_file(file_path: String) -> String ! FsError

Read a text file.

Examples

var content = fs.read_file("file.txt")
pub def read_bytes(file_path: String) -> List[Int] ! FsError

Read a file as raw bytes.

Examples

use fs from "std.fs"

const file = fs.create_temp_file("tea-bytes-")
fs.write_bytes(file, [0, 127, 255])
@println(fs.read_bytes(file)) # [0, 127, 255]
fs.remove(file)
pub def write_file(file_path: String, content: String) -> Void ! FsError

Write text to a file.

Examples

fs.write_file("file.txt", "Hello, world!")
pub def write_file_atomic(file_path: String, content: String) -> Void ! FsError

Write text to a file atomically.

Examples

use fs from "std.fs"

const file = fs.create_temp_file("tea-config-")
fs.write_file_atomic(file, "theme=dark\n")
@println(fs.read_file(file))
fs.remove(file)
pub def write_bytes(file_path: String, data: List[Int]) -> Void ! FsError

Write raw bytes to a file.

pub def write_bytes_atomic(file_path: String, data: List[Int]) -> Void ! FsError

Write raw bytes to a file atomically.

Examples

use fs from "std.fs"

const file = fs.create_temp_file("tea-bytes-")
fs.write_bytes_atomic(file, [0, 127, 255])
@println(fs.read_bytes(file)) # [0, 127, 255]
fs.remove(file)
pub def create_dir(dir_path: String) -> Void ! FsError

Create a directory.

Examples

fs.create_dir("my_dir")
pub def ensure_dir(dir_path: String) -> Void ! FsError

Create a directory and any missing parent directories.

pub def ensure_parent(file_path: String) -> Void ! FsError

Create any missing parent directories for a file path.

Examples

use fs from "std.fs"
use path from "std.path"

const directory = fs.create_temp_dir("tea-output-")
const file = path.join([directory, "reports", "summary.txt"])
fs.ensure_parent(file)
fs.write_file(file, "All checks passed")
@println(fs.exists(file)) # true
fs.remove(directory)
pub def mkdir_p(dir_path: String) -> Void ! FsError

Alias for ensure_dir().

pub def remove(file_path: String) -> Void ! FsError

Remove a file or directory.

Examples

fs.remove("file.txt")
pub def exists(file_path: String) -> Bool ! FsError

Return true when a path exists.

pub def is_symlink(file_path: String) -> Bool ! FsError

Return true when the path is a symbolic link.

pub def read_symlink(file_path: String) -> String ! FsError

Return the target path stored in a symbolic link.

pub def create_file_symlink(target_path: String, link_path: String) -> Void ! FsError

Create a symbolic link that points at a file target.

pub def create_dir_symlink(target_path: String, link_path: String) -> Void ! FsError

Create a symbolic link that points at a directory target.

pub def read_dir(dir_path: String) -> List[String] ! FsError

List all entries in a directory.

Examples

var entries = fs.read_dir(".")
pub def walk(dir_path: String) -> List[String] ! FsError

Recursively walk a directory and return full entry paths.

pub def glob(pattern: String) -> List[String] ! FsError

Return filesystem entries that match a glob pattern.

pub def copy(source_path: String, target_path: String) -> Void ! FsError

Copy a file to a new location.

pub def rename(source_path: String, target_path: String) -> Void ! FsError

Rename or move a file or directory.

pub def metadata(file_path: String) -> FileMetadata ! FsError

Get metadata information for a file or directory.

pub def stat(file_path: String) -> FileMetadata ! FsError

Alias for metadata().

pub def read_lines(file_path: String) -> List[String] ! FsError

Read a text file and split it into lines.

Examples

use fs from "std.fs"

const file = fs.create_temp_file("tea-lines-")
fs.write_lines(file, ["tea", "coffee"])
for line in fs.read_lines(file)
  @println(line)
end
fs.remove(file)
pub def write_lines(file_path: String, lines: List[String]) -> Void ! FsError

Write a list of lines to a file, joining them with "\n".

pub def append_bytes(file_path: String, data: List[Int]) -> Void ! FsError

Append raw bytes to a file, creating it when it does not exist.

pub def append_file(file_path: String, content: String) -> Void ! FsError

Append text to a file, creating it when it does not exist.

pub def create_temp_dir(prefix: String) -> String ! FsError

Create a unique temporary directory and return its path.

Examples

use fs from "std.fs"

const directory = fs.create_temp_dir("tea-example-")
@println(fs.exists(directory)) # true
fs.remove(directory)
pub def create_temp_file(prefix: String) -> String ! FsError

Create a unique temporary file and return its path.

Examples

use fs from "std.fs"

const file = fs.create_temp_file("tea-example-")
fs.write_file(file, "Hello, Tea!")
@println(fs.read_file(file)) # Hello, Tea!
fs.remove(file)