@zenfs/core
Version:
A filesystem, anywhere
83 lines (82 loc) • 2.28 kB
TypeScript
import type * as fs from 'node:fs';
import type { V_Context } from '../context.js';
import type { FileSystem } from '../internal/filesystem.js';
import type { InodeLike } from '../internal/inode.js';
import { type ExceptionExtra } from 'kerium';
import { type AbsolutePath } from '../path.js';
/**
* @internal @hidden
*/
export type MountObject = Record<AbsolutePath, FileSystem>;
/**
* The map of mount points
* @category Backends and Configuration
* @internal
*/
export declare const mounts: Map<string, FileSystem>;
/**
* Mounts the file system at `mountPoint`.
* @category Backends and Configuration
* @internal
*/
export declare function mount(this: V_Context, mountPoint: string, fs: FileSystem): void;
/**
* Unmounts the file system at `mountPoint`.
* @category Backends and Configuration
*/
export declare function umount(this: V_Context, mountPoint: string): void;
/**
* @internal @hidden
*/
export interface ResolvedMount {
fs: FileSystem;
path: string;
mountPoint: string;
root: string;
}
/**
* @internal @hidden
*/
export interface ResolvedPath extends ResolvedMount {
/** The real, absolute path */
fullPath: string;
/** Stats */
stats?: InodeLike;
}
/**
* Gets the internal `FileSystem` for the path, then returns it along with the path relative to the FS' root
* @internal @hidden
*/
export declare function resolveMount(path: string, ctx: V_Context, extra?: ExceptionExtra): ResolvedMount;
/**
* @internal @hidden
*/
export declare function _statfs<const T extends boolean>(fs: FileSystem, bigint?: T): T extends true ? fs.BigIntStatsFs : fs.StatsFs;
/**
* Change the root path
* @category Backends and Configuration
*/
export declare function chroot(this: V_Context, path: string): void;
export type FileContents = ArrayBufferView | string;
/**
* @internal @hidden Used for the internal `_open` functions
*/
export interface OpenOptions {
flag: fs.OpenMode;
mode?: fs.Mode | null;
/**
* If true, do not resolve symlinks
*/
preserveSymlinks?: boolean;
/**
* If true, allows opening directories
*/
allowDirectory?: boolean;
}
export interface MkdirOptions {
mode?: number;
recursive?: boolean;
}
export interface ReaddirOptions {
recursive?: boolean;
}