dofs
Version:
A filesystem for Cloudflare Durable Objects.
98 lines (97 loc) • 2.71 kB
TypeScript
import { RpcTarget } from "cloudflare:workers";
//#region src/Fs.d.ts
type CreateOptions = {
mode?: number;
umask?: number;
};
type DeviceStats = {
deviceSize: number;
spaceUsed: number;
spaceAvailable: number;
};
type ReadFileOptions = {
encoding?: string;
};
type WriteFileOptions = {
encoding?: string;
};
type ReadOptions = {
offset?: number;
length?: number;
encoding?: string;
};
type WriteOptions = {
offset?: number;
encoding?: string;
};
type MkdirOptions = {
recursive?: boolean;
} & CreateOptions;
type RmdirOptions = {
recursive?: boolean;
};
type ListDirOptions = {
recursive?: boolean;
};
type SetAttrOptions = {
mode?: number;
uid?: number;
gid?: number;
};
type Stat = {
isFile: boolean;
isDirectory: boolean;
size: number;
mode?: number;
uid?: number;
gid?: number;
mtime?: number;
ctime?: number;
atime?: number;
crtime?: number;
blocks?: number;
nlink?: number;
rdev?: number;
flags?: number;
blksize?: number;
kind?: string;
};
type FsOptions = {
chunkSize?: number;
};
declare class Fs extends RpcTarget {
protected ctx: DurableObjectState;
protected env: Env;
protected chunkSize: number;
constructor(ctx: DurableObjectState, env: Env, options?: FsOptions);
readFile(path: string, options?: ReadFileOptions): ReadableStream<Uint8Array<ArrayBufferLike>>;
writeFile(path: string, data: ArrayBuffer | string | ReadableStream<Uint8Array>, options?: WriteFileOptions): Promise<void>;
read(path: string, options: ReadOptions): ArrayBuffer;
write(path: string, data: ArrayBuffer | string, options: WriteOptions): void;
mkdir(path: string, options?: MkdirOptions): void;
rmdir(path: string, options?: RmdirOptions): void;
listDir(path: string, options?: ListDirOptions): string[];
stat(path: string): Stat;
setattr(path: string, options: SetAttrOptions): void;
symlink(target: string, path: string): void;
readlink(path: string): string;
rename(oldPath: string, newPath: string): void;
unlink(path: string): void;
create(path: string, options?: CreateOptions): void;
truncate(path: string, size: number): void;
getDeviceStats(): DeviceStats;
setDeviceSize(newSize: number): void;
private rootDirAttr;
private ensureSchema;
private resolvePathToInode;
private allocInode;
private loadChunk;
private getDeviceSize;
private getSpaceUsed;
private setSpaceUsed;
private updateFileSizeAndSpaceUsed;
}
//# sourceMappingURL=Fs.d.ts.map
//#endregion
export { CreateOptions, DeviceStats, Fs, FsOptions, ListDirOptions, MkdirOptions, ReadFileOptions, ReadOptions, RmdirOptions, SetAttrOptions, Stat, WriteFileOptions, WriteOptions };
//# sourceMappingURL=Fs-CX3m-F9L.d.ts.map