@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
26 lines • 1.4 kB
TypeScript
import { IOResult, type ByteSource } from '../../../io/types.ts';
import type { FileStat, PathSpec } from '../../../types.ts';
import { type FlagValue } from '../../spec/types.ts';
export type SizeMode = 'absolute' | 'extend' | 'reduce' | 'at_most' | 'at_least' | 'round_down' | 'round_up';
/**
* What `-s` asks of a file's size, as mirage-rs read it: how the number
* applies to the current size, and the number typed, its suffix applied. A
* bigint, since an off_t passes 2**53. Mirrors Python's `Size`.
*/
export interface Size {
readonly mode: SizeMode;
readonly number: bigint;
}
/** The length `size` asks for, given a file's current one. Mirrors Python's `resolve_size`. */
export declare function resolveSize(size: Size, current: bigint): bigint;
export interface TruncateFlags {
readonly size: Size;
readonly noCreate: boolean;
}
/**
* truncate's options, `-s` read by mirage-rs before any operand is resolved:
* the flags, or truncate's refusal. Mirrors Python's `parse_flags`.
*/
export declare function parseFlags(bag: Record<string, FlagValue>): TruncateFlags | IOResult;
export declare function truncateGeneric(paths: readonly PathSpec[], flags: TruncateFlags, stat: (path: PathSpec) => Promise<FileStat>, truncate: (path: PathSpec, length: number, noCreate: boolean) => Promise<void>): Promise<[ByteSource | null, IOResult]>;
//# sourceMappingURL=truncate.d.ts.map