import { FileType, Result, Whence } from "./snapshot-preview1.js"; import { WASIFile, WASIFS, WASIPath, WASITimestamps } from "../types.js"; type FileDescriptor = number; type DriveResult = [Exclude] | [Result.SUCCESS, T]; type DirectoryEntry = { name: string; type: FileType; }; export type DriveStat = { path: string; byteLength: number; timestamps: WASITimestamps; type: FileType; }; export declare class WASIDrive { fs: WASIFS; nextFD: FileDescriptor; openMap: Map; constructor(fs: WASIFS); private openFile; private openDir; private hasDir; open(fdDir: FileDescriptor, path: WASIPath, oflags: number, fdflags: number): DriveResult; close(fd: FileDescriptor): Result; read(fd: FileDescriptor, bytes: number): DriveResult; pread(fd: FileDescriptor, bytes: number, offset: number): DriveResult; write(fd: FileDescriptor, data: Uint8Array): Result; pwrite(fd: FileDescriptor, data: Uint8Array, offset: number): Result; sync(fd: FileDescriptor): Result; seek(fd: FileDescriptor, offset: bigint, whence: Whence): DriveResult; tell(fd: FileDescriptor): DriveResult; renumber(oldFd: FileDescriptor, newFd: FileDescriptor): Result; unlink(fdDir: FileDescriptor, path: string): Result; rename(oldFdDir: FileDescriptor, oldPath: string, newFdDir: FileDescriptor, newPath: string): Result; list(fd: FileDescriptor): DriveResult>; stat(fd: FileDescriptor): DriveResult; pathStat(fdDir: FileDescriptor, path: string): DriveResult; setFlags(fd: FileDescriptor, flags: number): Result; setSize(fd: FileDescriptor, size: bigint): Result; setAccessTime(fd: FileDescriptor, date: Date): Result; setModificationTime(fd: FileDescriptor, date: Date): Result; pathSetAccessTime(fdDir: FileDescriptor, path: string, date: Date): Result; pathSetModificationTime(fdDir: FileDescriptor, path: string, date: Date): Result; pathCreateDir(fdDir: FileDescriptor, path: string): Result; exists(fd: FileDescriptor): boolean; fileType(fd: FileDescriptor): FileType; fileFdflags(fd: FileDescriptor): number; } declare class OpenFile { file: WASIFile; buffer: Uint8Array; private _offset; isDirty: boolean; fdflags: number; flagAppend: boolean; flagDSync: boolean; flagNonBlock: boolean; flagRSync: boolean; flagSync: boolean; private get offset(); constructor(file: WASIFile, fdflags: number); read(bytes: number): Uint8Array; pread(bytes: number, offset: number): Uint8Array; write(data: Uint8Array): void; pwrite(data: Uint8Array, offset: number): void; sync(): void; seek(offset: bigint, whence: Whence): bigint; tell(): bigint; stat(): DriveStat; setFlags(flags: number): void; setSize(size: number): void; setAccessTime(date: Date): void; setModificationTime(date: Date): void; /** * Resizes the buffer to be exactly requiredBytes length, while resizing the * underlying buffer to be larger if necessary. * * Resizing will internally double the buffer size to reduce the need for * resizing often. * * @param requiredBytes how many bytes the buffer needs to have available */ private resize; } declare class OpenDirectory { dir: WASIFS; prefix: string; constructor(dir: WASIFS, prefix: string); containsFile(relativePath: string): boolean; containsDirectory(relativePath: string): boolean; contains(relativePath: string): boolean; get(relativePath: string): WASIFile | undefined; fullPath(relativePath: string): string; list(): Array; stat(): DriveStat; } export {};