FileSystem

dir_create

import { dir_create } from "std/fs"
pub fun dir_create(path: Text): Null

Creates a directory with all parent directories as required.

You can check the original tests for code examples:

dir_exists

import { dir_exists } from "std/fs"
pub fun dir_exists(path)

Checks if a directory exists.

You can check the original tests for code examples:

escape_non_glob_chars

import { escape_non_glob_chars } from "std/fs"
fun escape_non_glob_chars(path: Text): Text

Escapes all characters in the passed-in glob except "*", "?" and "/",
to prevent injection attacks.

file_append

import { file_append } from "std/fs"
pub fun file_append(path, content)

Appends content to a file.

Doesn't check if the file exists.

You can check the original tests for code examples:

file_chmod

import { file_chmod } from "std/fs"
pub fun file_chmod(path: Text, mode: Text): Bool

Changes the permission bits of a file.

If the file doesn't exist, it returns false and prints a message.

You can check the original tests for code examples:

file_chown

import { file_chown } from "std/fs"
pub fun file_chown(path: Text, user: Text): Bool

Changes the owner of a file.

If the file doesn't exist, it returns false and prints a message.

You can check the original tests for code examples:

file_exists

import { file_exists } from "std/fs"
pub fun file_exists(path)

Checks if a file exists.

You can check the original tests for code examples:

file_extract

import { file_extract } from "std/fs"
pub fun file_extract(path: Text, target: Text): Null ?

Extract the file detecting from the filename the extension
Supports: bz2, gz, xz, bz2, deb, rar, rpm, tar(gz/xz/bz), zip(war/jar), 7z
Note: Not all the commands supports the output folder path

You can check the original tests for code examples:

file_glob

import { file_glob } from "std/fs"
pub fun file_glob(path: Text): [Text] ?

Finds all files or directories matching a file glob.

You can check the original tests for code examples:

file_glob_all

import { file_glob_all } from "std/fs"
pub fun file_glob_all(paths: [Text]): [Text] ?

Finds all files or directories matching multiple file globs. When
we have union types, this functionality can be merged into the main
glob function.

file_read

import { file_read } from "std/fs"
pub fun file_read(path)

Gets file contents from a path.

You can check the original tests for code examples:

file_write

import { file_write } from "std/fs"
pub fun file_write(path, content)

Writes content to a file.
Doesn't check if the file exist

You can check the original tests for code examples:

import { symlink_create } from "std/fs"
pub fun symlink_create(origin: Text, destination: Text): Bool

Creates a symbolic link.

If the file doesn't exist, it returns a boolean and prints a message.

You can check the original tests for code examples: