Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/fs/mod.ts

The Deno Standard Library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
import * as mod from "https://deno.land/std@0.222.1/fs/mod.ts";

Helpers for working with the filesystem.

import { ensureFile, copy, ensureDir, move } from "https://deno.land/std@0.222.1/fs/mod.ts";

await ensureFile("example.txt");
await copy("example.txt", "example_copy.txt");
await ensureDir("subdir");
await move("example_copy.txt", "subdir/example_copy.txt");

Classes

Error thrown in move or moveSync when the destination is a subdirectory of the source.

Error thrown in walk or walkSync during iteration.

Variables

End-of-line character for Windows platforms.

End-of-line character evaluated for the current platform.

End-of-line character for POSIX platforms such as macOS and Linux.

Functions

Asynchronously copy a file or directory. The directory can have contents. Like cp -r.

Synchronously copy a file or directory. The directory can have contents. Like cp -r.

Returns the detected EOL character(s) detected in the input string. If no EOL character is detected, null is returned.

Asynchronously ensures that a directory is empty deletes the directory contents it is not empty. If the directory does not exist, it is created. The directory itself is not deleted.

Synchronously ensures that a directory is empty deletes the directory contents it is not empty. If the directory does not exist, it is created. The directory itself is not deleted.

Asynchronously ensures that the directory exists. If the directory structure does not exist, it is created. Like mkdir -p.

Synchronously ensures that the directory exists. If the directory structure does not exist, it is created. Like mkdir -p.

Asynchronously ensures that the file exists. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is not modified.

Synchronously ensures that the file exists. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is not modified.

Asynchronously ensures that the hard link exists. If the directory structure does not exist, it is created.

Synchronously ensures that the hard link exists. If the directory structure does not exist, it is created.

Asynchronously ensures that the link exists, and points to a valid file. If the directory structure does not exist, it is created. If the link already exists, it is not modified but error is thrown if it is not point to the given target.

Synchronously ensures that the link exists, and points to a valid file. If the directory structure does not exist, it is created. If the link already exists, it is not modified but error is thrown if it is not point to the given target.

Asynchronously test whether or not the given path exists by checking with the file system.

Synchronously test whether or not the given path exists by checking with the file system.

Returns an async iterator that yields each file path matching the given glob pattern. The file paths are relative to the provided root directory. If root is not provided, the current working directory is used. The root directory is not included in the yielded file paths.

Returns an iterator that yields each file path matching the given glob pattern. The file paths are relative to the provided root directory. If root is not provided, the current working directory is used. The root directory is not included in the yielded file paths.

Normalize the input string to the targeted EOL.

Asynchronously moves a file or directory.

Synchronously moves a file or directory.

Recursively walks through a directory and yields information about each file and directory encountered.

Same as walk but uses synchronous ops

Interfaces

Options for copy and copySync.

Options for exists and existsSync.

Options for expandGlob and expandGlobSync.

Options for globToRegExp.

Options for move and moveSync.

Walk entry for walk, walkSync, expandGlob and expandGlobSync.

Options for walk and walkSync.