@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
80 lines • 3.79 kB
TypeScript
import { type FileStat } from '../types.ts';
export declare const S_IFMT = 61440;
export declare const S_IFDIR = 16384;
export declare const S_IFCHR = 8192;
export declare const S_IFREG = 32768;
export declare const S_IFLNK = 40960;
export declare const CHAR_MODE: number;
export declare const DIR_MODE: number;
export declare const FILE_MODE: number;
export declare const FIFO_MODE: number;
export declare const LINK_MODE: number;
export declare const DIR_SIZE = 4096;
export declare const BLKSIZE = 4096;
export declare const BLOCK_UNIT = 512;
export declare const ALL_MODE_BITS = 4095;
/**
* A stable, distinct id for one name, as a stat's ino and dev: derived
* from the name rather than counted, so two processes reading the same
* workspace agree and a repeated stat of one path does not move. The top
* 48 bits of the hash, which a number holds exactly. Mirrors Python's
* `ident`.
*/
export declare function ident(text: string): number;
/**
* A FileStat's mtime as epoch milliseconds, null when unknown.
*
* Delegates to `isoTimestamp` rather than re-parsing, which is the
* whole point: an offset-less stamp is read as UTC so every translator
* (the FUSE attr fold, the runtime bridge, python's twins) answers the
* same epoch, instead of drifting by the host's UTC offset the way a
* bare `Date.parse`/`new Date` does. Null (missing or unparseable
* stamp) is distinct from 0, which is the real answer for
* 1970-01-01T00:00:00Z; a wire with no validity channel collapses the
* two at its own boundary.
*/
export declare function mtimeMs(st: FileStat): number | null;
/** A FileStat's atime as epoch milliseconds, null when unknown. */
export declare function atimeMs(st: FileStat): number | null;
/** Whether a FileStat describes a directory. */
export declare function isDir(st: FileStat): boolean;
/** Whether a FileStat describes a symlink. */
export declare function isLink(st: FileStat): boolean;
/** Whether a FileStat describes a character device. */
export declare function isCharDevice(st: FileStat): boolean;
/** Whether a FileStat describes a FIFO. */
export declare function isFifo(st: FileStat): boolean;
/** Encode a character device's logical major:minor for guest stat. */
export declare function deviceRdev(st: FileStat): number;
/**
* The st_mode a stat consumer should report for one FileStat.
*
* The type bits come from the entry's kind and the permission bits from
* the namespace overlay when a chmod put one there, which is what makes
* a metadata write visible to a guest and to a mount alike. A backend
* that reports no mode keeps the default rw-r--r-- / rwxr-xr-x pair
* (rw------- for a FIFO); there are no permissions to read on an object
* store.
*
* A link is the exception in both halves: its type bits are S_IFLNK and
* its permission bits are always 0777, because no POSIX system consults
* the bits on a symlink. An overlay mode a `chmod -h` wrote is
* therefore not reported here (ownership is, since `chown -h` does
* change what `ls -l` shows). Mirrors python's posix_mode.
*/
export declare function posixMode(st: FileStat): number;
/**
* The byte size a stat consumer should report, 0 when unknown.
*
* A directory is always `DIR_SIZE`, whatever aggregate a backend put in
* `size` (Graph folders report a subtree total there); an unknown file
* size is 0 and rides the unknown-size machinery above.
*/
export declare function contentSize(st: FileStat): number;
/**
* Whether a listing has no size to show for one FileStat. A directory shows
* `DIR_SIZE` and a FIFO, which stores nothing, 0 (as GNU's `stat` and `ls -l`
* do); any other entry its rendered length. Mirrors python's size_unknown.
*/
export declare function sizeUnknown(st: FileStat): boolean;
//# sourceMappingURL=stat_view.d.ts.map