WasiFile
12 types41 functionsFile access for the component target, over wasi:filesystem: whole-file
reads and writes, directory listings and one-level directory changes, in
File's types. Contents are Bytes; readText and writeText cross to
String through UTF-8.
A path is read against the directories the host grants, its preopens. An
absolute path is read in the preopen whose guest path is its longest
prefix, and a relative one in the relative preopen that covers the most of
it โ . covers every relative path. The path is normalized first, and one
that climbs out of where it starts, or that no preopen covers, is
OutsideSandbox without asking the host to open it. Every failure is
FileErr(path, kind) with the path as the caller wrote it.
Every descriptor and stream opened here is dropped before the function returns, on a failure too.
At a glance
Types
@Descriptor
The descriptor resource of wasi:filesystem/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropDescriptor.
@DirectoryEntryStream
The directory-entry-stream resource of wasi:filesystem/types@0.2.3, as a
handle. It comes only from the functions here that return one. Release it
with dropDirectoryEntryStream.
ErrorCode
The view of WIT's error-code type, from wasi:filesystem/types@0.2.3.
Advice
The view of WIT's advice type, from wasi:filesystem/types@0.2.3.
DescriptorFlags
The view of WIT's descriptor-flags type, from
wasi:filesystem/types@0.2.3.
DescriptorType
The view of WIT's descriptor-type type, from
wasi:filesystem/types@0.2.3.
NewTimestamp
The view of WIT's new-timestamp type, from wasi:filesystem/types@0.2.3.
DescriptorStat
The view of WIT's descriptor-stat type, from
wasi:filesystem/types@0.2.3.
PathFlags
The view of WIT's path-flags type, from wasi:filesystem/types@0.2.3.
OpenFlags
The view of WIT's open-flags type, from wasi:filesystem/types@0.2.3.
MetadataHashValue
The view of WIT's metadata-hash-value type, from
wasi:filesystem/types@0.2.3.
DirectoryEntry
The view of WIT's directory-entry type, from
wasi:filesystem/types@0.2.3.
Functions
read
The whole file. A directory is IsDirectory, and anything else that is not
a regular file, such as a device or a fifo, is HostError("not a regular file"), since reading one may never end. A file that grows while it is read
is read as long as it was when the read began.
readText
The whole file as text: InvalidUtf8 at the first byte that is not strict
UTF-8.
write
Creates the file, or truncates one that exists, and writes bytes to it.
writeText
Writes text to the file as UTF-8, as write writes bytes.
append
Writes bytes after the end of the file, creating it if it is missing.
delete
A file, not a directory: a directory is IsDirectory.
list
The entries directly inside a directory, without . and .., in the order
the host lists them, which is not sorted.
makeDir
One level: a missing parent is NotFound.
removeDir
Only an empty directory: anything inside it is NotEmpty.
descriptorReadViaStream
WIT's descriptor.read-via-stream method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorWriteViaStream
WIT's descriptor.write-via-stream method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorAppendViaStream
WIT's descriptor.append-via-stream method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorAdvise
WIT's descriptor.advise method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorSyncData
WIT's descriptor.sync-data method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorGetFlags
WIT's descriptor.get-flags method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorGetType
WIT's descriptor.get-type method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorSetSize
WIT's descriptor.set-size method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorSetTimes
WIT's descriptor.set-times method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorRead
WIT's descriptor.read method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorWrite
WIT's descriptor.write method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorReadDirectory
WIT's descriptor.read-directory method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorSync
WIT's descriptor.sync method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorCreateDirectoryAt
WIT's descriptor.create-directory-at method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorStat
WIT's descriptor.stat method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorStatAt
WIT's descriptor.stat-at method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorSetTimesAt
WIT's descriptor.set-times-at method, from wasi:filesystem/types@0.2.3,
in Bert's view of its types.
descriptorLinkAt
WIT's descriptor.link-at method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorOpenAt
WIT's descriptor.open-at method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorReadlinkAt
WIT's descriptor.readlink-at method, from wasi:filesystem/types@0.2.3,
in Bert's view of its types.
descriptorRemoveDirectoryAt
WIT's descriptor.remove-directory-at method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorRenameAt
WIT's descriptor.rename-at method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorSymlinkAt
WIT's descriptor.symlink-at method, from wasi:filesystem/types@0.2.3, in
Bert's view of its types.
descriptorUnlinkFileAt
WIT's descriptor.unlink-file-at method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorIsSameObject
WIT's descriptor.is-same-object method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
descriptorMetadataHash
WIT's descriptor.metadata-hash method, from wasi:filesystem/types@0.2.3,
in Bert's view of its types.
descriptorMetadataHashAt
WIT's descriptor.metadata-hash-at method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
directoryEntryStreamReadDirectoryEntry
WIT's directory-entry-stream.read-directory-entry method, from
wasi:filesystem/types@0.2.3, in Bert's view of its types.
filesystemErrorCode
WIT's filesystem-error-code function, from wasi:filesystem/types@0.2.3,
in Bert's view of its types.
dropDescriptor
Drops the descriptor handle, from wasi:filesystem/types@0.2.3. Nothing
else releases it, and the handle is not used after.
dropDirectoryEntryStream
Drops the directory-entry-stream handle, from
wasi:filesystem/types@0.2.3. Nothing else releases it, and the handle is
not used after.
getDirectories
WIT's get-directories function, from wasi:filesystem/preopens@0.2.3, in
Bert's view of its types.