import { StreamReader } from "../stream.js"; import { FutureReader } from "../future.js"; declare const symbolDispose: symbol; declare class Descriptor { #private; [symbolDispose]: () => void; static _create(handle: any, mode: any, fullPath: any, isDirectory?: boolean): Descriptor; static _createPreopen(hostPreopen: any): Descriptor; /** * Return a stream for reading from a file. * WIT: * ``` * read-via-stream: func(offset: filesize) -> tuple, future>> * ``` * * @param {bigint} offset The offset within the file. * @returns {{stream: StreamReader, future: FutureReader}} * A tuple: a readable byte stream and a future that resolves to an error code. * @throws {FSError} `payload.tag` contains mapped WASI error code. */ readViaStream(offset: any): (StreamReader | FutureReader)[]; /** * Write to a file via a byte stream. * WIT: * ``` * write-via-stream: async func(data: stream, offset: filesize) -> result<_, error-code> * ``` * * @async * @param {object} data A readable byte stream. * @param {bigint} offset The offset within the file. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ writeViaStream(data: any, offset: any): Promise; /** * Append to a file via a byte stream. * WIT: * ``` * append-via-stream: async func(data: stream) -> result<_, error-code> * ``` * * @async * @param {object} data A readable byte stream. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ appendViaStream(data: any): Promise; /** * Advisory on file access patterns. * WIT: * ``` * advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code> * ``` * * @async * @param {bigint} offset Start of the region. * @param {bigint} length Length of the region. * @param {string} advice One of the Wasi `advice` values. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ advise(_offset: any, _length: any, _advice: any): Promise; /** * Synchronize file data to disk. * WIT: * ``` * sync-data: async func() -> result<_, error-code> * ``` * * @async * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ syncData(): Promise; /** * Get flags associated with a descriptor. * WIT: * ``` * get-flags: async func() -> result * ``` * * @async * @returns {Promise} The descriptor flags object. * @throws {FSError} `payload.tag` contains mapped WASI error code. */ getFlags(): Promise; /** * Get the dynamic type of a descriptor. * WIT: * ``` * get-type: async func() -> result * ``` * * @async * @returns {Promise} The descriptor type. * @throws {FSError} `payload.tag` contains mapped WASI error code. */ getType(): Promise<{ tag: string; val?: undefined; } | { tag: string; val: any; }>; /** * Adjust the size of an open file. * WIT: * ``` * set-size: async func(size: filesize) -> result<_, error-code> * ``` * * @async * @param {bigint} size The new size. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ setSize(size: any): Promise; /** * Adjust the timestamps of an open file or directory. * WIT: * ``` * set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code> * ``` * * @async * @param {object} atimeDesc new-timestamp descriptor * @param {object} mtimeDesc new-timestamp descriptor * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ setTimes(atimeDesc: any, mtimeDesc: any): Promise; /** * Read directory entries via a stream. * WIT: * ``` * read-directory: async func() -> tuple, future>> * ``` * * @async * @returns {{stream: StreamReader, future: FutureReader}} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ readDirectory(): (StreamReader | FutureReader)[]; /** * Synchronize data & metadata to disk. * WIT: * ``` * sync: async func() -> result<_, error-code> * ``` * * @async * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ sync(): Promise; /** * Create a directory. * WIT: * ``` * create-directory-at: async func(path: string) -> result<_, error-code> * ``` * * @async * @param {string} path Relative path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ createDirectoryAt(path: any): Promise; /** * Return attributes of an open file or directory. * WIT: * ``` * stat: async func() -> result * ``` * * @async * @returns {Promise} File statistics. * @throws {FSError} `payload.tag` contains mapped WASI error code. */ stat(): Promise<{ type: { tag: string; val?: undefined; } | { tag: string; val: any; }; linkCount: any; size: any; dataAccessTimestamp: { seconds: bigint; nanoseconds: number; }; dataModificationTimestamp: { seconds: bigint; nanoseconds: number; }; statusChangeTimestamp: { seconds: bigint; nanoseconds: number; }; }>; /** * Adjust timestamps on a file or symlink. * WIT: * ``` * set-times-at: async func( * path-flags: path-flags, * path: string, * data-access-timestamp: new-timestamp, * data-modification-timestamp: new-timestamp * ) -> result<_, error-code> * ``` * * @async * @param {object} flags Path flags. * @param {string} path Relative path. * @param {object} atimeDesc New access timestamp. * @param {object} mtimeDesc New modification timestamp. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ statAt(flags: any, path: any): Promise<{ type: { tag: string; val?: undefined; } | { tag: string; val: any; }; linkCount: bigint; size: bigint; dataAccessTimestamp: { seconds: bigint; nanoseconds: number; }; dataModificationTimestamp: { seconds: bigint; nanoseconds: number; }; statusChangeTimestamp: { seconds: bigint; nanoseconds: number; }; }>; /** * Adjust timestamps on a file or symlink. * WIT: * ``` * set-times-at: async func( * path-flags: path-flags, * path: string, * data-access-timestamp: new-timestamp, * data-modification-timestamp: new-timestamp * ) -> result<_, error-code> * ``` * * @async * @param {object} flags Path flags. * @param {string} path Relative path. * @param {object} atimeDesc New access timestamp. * @param {object} mtimeDesc New modification timestamp. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ setTimesAt(flags: any, path: any, atimeDesc: any, mtimeDesc: any): Promise; /** * Create a hard link. * WIT: * ``` * link-at: async func( * old-path-flags: path-flags, * old-path: string, * new-descriptor: borrow, * new-path: string * ) -> result<_, error-code> * ``` * * @async * @param {object} oldFlags Old path flags. * @param {string} oldPath Source path. * @param {Descriptor} newDesc Target descriptor. * @param {string} newPath Destination path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ linkAt(oldFlags: any, oldPath: any, newDesc: any, newPath: any): Promise; /** * Open a file or directory. * WIT: * ``` * open-at: async func( * path-flags: path-flags, * path: string, * open-flags: open-flags, * %flags: descriptor-flags * ) -> result * ``` * * @async * @param {object} pf - path flags * @param {string} path - relative path * @param {object} of - open flags * @param {object} df - descriptor flags * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ openAt(pf: any, path: any, of: any, df: any): Promise; /** * Read the contents of a symbolic link. * WIT: * ``` * readlink-at: async func(path: string) -> result * ``` * * @async * @param {string} path Relative path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ readlinkAt(path: any): Promise; /** * Remove a directory. * WIT: * ``` * remove-directory-at: async func(path: string) -> result<_, error-code> * ``` * * @async * @param {string} path Relative path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ removeDirectoryAt(path: any): Promise; /** * Rename a filesystem object. * WIT: * ``` * rename-at: async func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code> * ``` * * @async * @param {string} oldPath Source path. * @param {Descriptor} newDesc Target descriptor. * @param {string} newPath Destination path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ renameAt(oldPath: any, newDesc: any, newPath: any): Promise; /** * Create a symbolic link. * WIT: * ``` * symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code> * ``` * * @async * @param {string} target Link target. * @param {string} path Destination path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ symlinkAt(target: any, path: any): Promise; /** * Unlink a filesystem object that is not a directory. * WIT: * ``` * unlink-file-at: async func(path: string) -> result<_, error-code> * ``` * * @async * @param {string} path Relative path. * @returns {Promise} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ unlinkFileAt(path: any): Promise; /** * Test whether two descriptors refer to the same object. * WIT: * ``` * is-same-object: async func(other: borrow) -> bool * ``` * * @async * @param {Descriptor} other Another descriptor. * @returns {Promise} */ isSameObject(other: any): Promise; /** * Return a hash of the metadata associated with this descriptor. * WIT: * ``` * metadata-hash: async func() -> result * ``` * * @async * @returns {Promise<{upper: bigint, lower: bigint}>} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ metadataHash(): Promise<{ upper: any; lower: any; }>; /** * Return a hash of the metadata via path. * WIT: * ``` * metadata-hash-at: async func(path-flags: path-flags, path: string) -> result * ``` * * @async * @param {object} flags Path flags. * @param {string} path Relative path. * @returns {Promise<{upper: bigint, lower: bigint}>} * @throws {FSError} `payload.tag` contains mapped WASI error code. */ metadataHashAt(flags: any, path: any): Promise<{ upper: bigint; lower: bigint; }>; } export declare const preopens: { Descriptor: typeof Descriptor; getDirectories: () => any[]; }; export declare const types: { Descriptor: typeof Descriptor; }; /** * Set the preopen table. * * @param {Record} entries */ export declare function _setPreopens(entries: any): void; /** * Add a new preopen mapping. * * @param {string} virtualPath * @param {string} hostPreopen */ export declare function _addPreopen(virtualPath: any, hostPreopen: any): void; export {};