package wasi:filesystem@0.2.0; interface types { use wasi:io/streams@0.2.0.{input-stream, output-stream, error}; use wasi:clocks/wall-clock@0.2.0.{datetime}; type filesize = u64; enum descriptor-type { unknown, block-device, character-device, directory, fifo, symbolic-link, regular-file, socket, } flags descriptor-flags { read, write, file-integrity-sync, data-integrity-sync, requested-write-sync, mutate-directory, } flags path-flags { symlink-follow, } flags open-flags { create, directory, exclusive, truncate, } type link-count = u64; record descriptor-stat { %type: descriptor-type, link-count: link-count, size: filesize, data-access-timestamp: option, data-modification-timestamp: option, status-change-timestamp: option, } variant new-timestamp { no-change, now, timestamp(datetime), } record directory-entry { %type: descriptor-type, name: string, } enum error-code { access, would-block, already, bad-descriptor, busy, deadlock, quota, exist, file-too-large, illegal-byte-sequence, in-progress, interrupted, invalid, io, is-directory, loop, too-many-links, message-size, name-too-long, no-device, no-entry, no-lock, insufficient-memory, insufficient-space, not-directory, not-empty, not-recoverable, unsupported, no-tty, no-such-device, overflow, not-permitted, pipe, read-only, invalid-seek, text-file-busy, cross-device, } enum advice { normal, sequential, random, will-need, dont-need, no-reuse, } record metadata-hash-value { lower: u64, upper: u64, } resource descriptor { read-via-stream: func(offset: filesize) -> result; write-via-stream: func(offset: filesize) -> result; append-via-stream: func() -> result; advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; sync-data: func() -> result<_, error-code>; get-flags: func() -> result; get-type: func() -> result; set-size: func(size: filesize) -> result<_, error-code>; set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; read: func(length: filesize, offset: filesize) -> result, bool>, error-code>; write: func(buffer: list, offset: filesize) -> result; read-directory: func() -> result; sync: func() -> result<_, error-code>; create-directory-at: func(path: string) -> result<_, error-code>; stat: func() -> result; stat-at: func(path-flags: path-flags, path: string) -> result; set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; readlink-at: func(path: string) -> result; remove-directory-at: func(path: string) -> result<_, error-code>; rename-at: func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>; unlink-file-at: func(path: string) -> result<_, error-code>; is-same-object: func(other: borrow) -> bool; metadata-hash: func() -> result; metadata-hash-at: func(path-flags: path-flags, path: string) -> result; } resource directory-entry-stream { read-directory-entry: func() -> result, error-code>; } filesystem-error-code: func(err: borrow) -> option; } interface preopens { use types.{descriptor}; get-directories: func() -> list>; }