Conversation
kelnishi
added a commit
that referenced
this pull request
Apr 27, 2026
Adds directory iteration — guests walking a tree call
read-directory once per directory and pull entries via
read-directory-entry until None signals exhausted.
read-directory() -> result<own<directory-entry-stream>, error-code>
resource directory-entry-stream {
read-directory-entry: func()
-> result<option<directory-entry>, error-code>;
}
record directory-entry {
type: descriptor-type,
name: string,
}
Types added:
- DirectoryEntry class (Type: DescriptorType, Name: string)
- DirectoryEntryStream resource — array-backed by default;
pos cursor advances on each ReadDirectoryEntry call;
null when exhausted.
Descriptor.ReadDirectory() default impl walks
Directory.EnumerateDirectories + Directory.EnumerateFiles
on the underlying Path, builds a DirectoryEntry[] with
the appropriate DescriptorType per entry. Subclasses
override for VFS shims.
WasiInterfaceBinder.BindStreamResultResourceMethod gains
return shape #13: option<directory-entry>. 20-byte total
layout:
- +0: outer disc (Ok)
- +4: option disc (None=0, Some=1)
- +8: type (u8)
- +12: name ptr (i32)
- +16: name len (i32)
When Some: type byte at +8, name UTF-8 bytes allocated
via cabi_realloc with (ptr, len) at +12/+16.
WIT keyword "type" can't be used as a field name without
escaping; the dep .wit uses "%type" to satisfy
wasm-tools.
wasi-fs-readdir-component fixture: hand-written WAT
chains read-directory → read-directory-entry, packs
(option-disc, type, name-len, first-name-byte) into a u32.
Stub yields ("first.txt", RegularFile) as the first entry;
test asserts each packed byte matches.
Test counts (sequential): 603 transpiler + 344 component-
model + 7 bindgen + 73 WASI.Preview2 = 1027/1027 passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.