Skip to content

stat ​

Returns statistics about a file or directory. Invalid paths return Err with ERR_FS_INVALID_PATH; paths that cannot be inspected return Err with ERR_FS_STAT_FAILED.

When path is a symbolic link, the statistics describe its target and isSymlink is true for the original path.

Signaturestat(path: string): Result<FileStats, FsError>

Fields ​

FieldTypeDescription
sizeu64File size in bytes.
isFilebooleanTrue if the path is a file.
isDirectorybooleanTrue if the path is a directory.
isSymlinkbooleanTrue if the path is a symbolic link.
modifiedu64Last modification time (Unix epoch seconds).
createdu64Creation time (Unix epoch seconds).
permissionsu32File permission bits.

For an accessible path on non-Unix platforms, permissions is 0; this API exposes POSIX permission bits and does not translate Windows ACLs.

Example ​

tyrus
import { stat, type FileStats, type FsError } from "tyrus:fs";

const result: Result<FileStats, FsError> = stat("./message.txt");
match (result) {
    Ok(info) => {
        print(info.size); // 18
        print(info.isFile); // true
        print(info.isDirectory); // false
    },
    Err(_) => {},
}