@zenfs/core
Version:
A filesystem, anywhere
132 lines (131 loc) • 3.82 kB
TypeScript
import type { CreationOptions, UsageInfo } from '../internal/filesystem.js';
import { FileSystem } from '../internal/filesystem.js';
import { type InodeLike } from '../internal/inode.js';
import type { NodeFS } from '../node/types.js';
/**
* Passthrough backend options
* @category Backends and Configuration
*/
export interface PassthroughOptions {
fs: NodeFS;
prefix: string;
}
export declare class PassthroughFS extends FileSystem {
readonly nodeFS: NodeFS;
readonly prefix: string;
constructor(nodeFS: NodeFS, prefix: string);
usage(): UsageInfo;
path(path: string): string;
/**
* Rename a file or directory.
*/
rename(oldPath: string, newPath: string): Promise<void>;
/**
* Rename a file or directory synchronously.
*/
renameSync(oldPath: string, newPath: string): void;
/**
* Get file statistics.
*/
stat(path: string): Promise<InodeLike>;
/**
* Get file statistics synchronously.
*/
statSync(path: string): InodeLike;
/**
* @privateRemarks
* Timestamps should be updated by the underlying file system.
*/
touch(path: string, metadata: InodeLike): Promise<void>;
/**
* @privateRemarks
* Timestamps should be updated by the underlying file system.
*/
touchSync(path: string, metadata: InodeLike): void;
/**
* Unlink (delete) a file.
*/
unlink(path: string): Promise<void>;
/**
* Unlink (delete) a file synchronously.
*/
unlinkSync(path: string): void;
/**
* Create a directory.
*/
mkdir(path: string, options: CreationOptions): Promise<InodeLike>;
/**
* Create a directory synchronously.
*/
mkdirSync(path: string, options: CreationOptions): InodeLike;
/**
* Read the contents of a directory.
*/
readdir(path: string): Promise<string[]>;
/**
* Read the contents of a directory synchronously.
*/
readdirSync(path: string): string[];
/**
* Create a file.
*/
createFile(path: string, options: CreationOptions): Promise<InodeLike>;
/**
* Create a file synchronously.
*/
createFileSync(path: string, options: CreationOptions): InodeLike;
/**
* Remove a directory.
*/
rmdir(path: string): Promise<void>;
/**
* Remove a directory synchronously.
*/
rmdirSync(path: string): void;
/**
* Synchronize data to the file system.
*/
sync(): Promise<void>;
/**
* Synchronize data to the file system synchronously.
*/
syncSync(): void;
/**
* Create a hard link.
*/
link(target: string, link: string): Promise<void>;
/**
* Create a hard link synchronously.
*/
linkSync(target: string, link: string): void;
read(path: string, buffer: Uint8Array, offset: number, end: number): Promise<void>;
readSync(path: string, buffer: Uint8Array, offset: number, end: number): void;
write(path: string, buffer: Uint8Array, offset: number): Promise<void>;
writeSync(path: string, buffer: Uint8Array, offset: number): void;
}
declare const _Passthrough: {
readonly name: "Passthrough";
readonly options: {
readonly fs: {
readonly type: "object";
readonly required: true;
};
readonly prefix: {
readonly type: "string";
readonly required: true;
};
};
readonly create: ({ fs, prefix }: PassthroughOptions) => PassthroughFS;
};
type _Passthrough = typeof _Passthrough;
/**
* A file system that passes through to another FS
* @category Backends and Configuration
*/
export interface Passthrough extends _Passthrough {
}
/**
* A file system that passes through to another FS
*/
export declare const Passthrough: Passthrough;
export {};