cp
Copies a file or directory from src to dest. For directories, use { recursive: true }.
Signature
cp(src: string, dest: string, options?: CpOptions): Result<void, FsError>The operation returns Err(FsError) on failure; inspect it with match or propagate it with ?.
Options
CpOptions is an interface with two optional fields:
recursive?: boolean, whentrue, copies directories recursively. Required for directory sources. Defaults tofalse.force?: boolean, whentrue, overwrites existing files at the destination. Defaults tofalse.
Example
tyrus
import { cp, type FsError } from "tyrus:fs";
match (cp("source.txt", "dest.txt")) {
Ok(_) => {}
Err(error) => { printError(error.code); // ERR_FS_CP_FAILED
}
}