Skip to content

Commit

Permalink
Add an is_directory() helper method. (#1373)
Browse files Browse the repository at this point in the history
This allows `ctx` to avoid depending on wasi::FileType.
  • Loading branch information
sunfishcode committed Mar 20, 2020
1 parent a7d84af commit 815e340
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/wasi-common/src/ctx.rs
Expand Up @@ -351,7 +351,7 @@ impl WasiCtxBuilder {
}
}
Descriptor::VirtualFile(virt) => {
if virt.get_file_type() != types::Filetype::Directory {
if !virt.is_directory() {
return Err(WasiCtxBuilderError::NotADirectory(guest_path));
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/wasi-common/src/virtfs.rs
Expand Up @@ -137,6 +137,10 @@ pub(crate) trait VirtualFile: MovableFile {

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

fn is_directory(&self) -> bool {
self.get_file_type() == types::Filetype::Directory
}

fn get_rights_base(&self) -> types::Rights {
types::Rights::empty()
}
Expand Down

0 comments on commit 815e340

Please sign in to comment.