Skip to content

Commit 815e340

Browse files
authored
Add an is_directory() helper method. (bytecodealliance#1373)
This allows `ctx` to avoid depending on wasi::FileType.
1 parent a7d84af commit 815e340

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/wasi-common/src/ctx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl WasiCtxBuilder {
351351
}
352352
}
353353
Descriptor::VirtualFile(virt) => {
354-
if virt.get_file_type() != types::Filetype::Directory {
354+
if !virt.is_directory() {
355355
return Err(WasiCtxBuilderError::NotADirectory(guest_path));
356356
}
357357
}

crates/wasi-common/src/virtfs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ pub(crate) trait VirtualFile: MovableFile {
137137

138138
fn get_file_type(&self) -> types::Filetype;
139139

140+
fn is_directory(&self) -> bool {
141+
self.get_file_type() == types::Filetype::Directory
142+
}
143+
140144
fn get_rights_base(&self) -> types::Rights {
141145
types::Rights::empty()
142146
}

0 commit comments

Comments
 (0)