Skip to content

diff ​

Compares two files or directories and returns a DiffResult describing the differences.

Signaturediff(path1: string, path2: string): Result<DiffResult, FsError>

DiffResult fields ​

FieldTypeDescription
addedstring[]Files present in path1 but not path2.
removedstring[]Files present in path2 but not path1.
modifiedstring[]Files present in both but with different contents.
unchangedstring[]Files present in both with identical contents.

Error handling ​

Returns Err(FsError) with code ERR_FS_DIFF_FAILED if either path cannot be inspected, a directory cannot be listed, or a matching file cannot be read. The operation does not report failed reads as differences.

Example ​

tyrus
import { diff, FsError } from "tyrus:fs";

match (diff("./dir1", "./dir2")) {
    Ok(result) => { print(result.added.length); } // 1
    Err(error) => { printError(error.code); } // ERR_FS_DIFF_FAILED
}