diff
Compares two files or directories and returns a DiffResult describing the differences.
Signature
diff(path1: string, path2: string): Result<DiffResult, FsError>DiffResult fields
| Field | Type | Description |
|---|---|---|
added | string[] | Files present in path1 but not path2. |
removed | string[] | Files present in path2 but not path1. |
modified | string[] | Files present in both but with different contents. |
unchanged | string[] | 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
}