Browse Source
Add an `is_directory()` helper method. (#1373)
This allows `ctx` to avoid depending on wasi::FileType.
pull/1381/head
Dan Gohman
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
1 deletions
-
crates/wasi-common/src/ctx.rs
-
crates/wasi-common/src/virtfs.rs
|
@ -351,7 +351,7 @@ impl WasiCtxBuilder { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Descriptor::VirtualFile(virt) => { |
|
|
Descriptor::VirtualFile(virt) => { |
|
|
if virt.get_file_type() != types::Filetype::Directory { |
|
|
if !virt.is_directory() { |
|
|
return Err(WasiCtxBuilderError::NotADirectory(guest_path)); |
|
|
return Err(WasiCtxBuilderError::NotADirectory(guest_path)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
@ -137,6 +137,10 @@ pub(crate) trait VirtualFile: MovableFile { |
|
|
|
|
|
|
|
|
fn get_file_type(&self) -> types::Filetype; |
|
|
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 { |
|
|
fn get_rights_base(&self) -> types::Rights { |
|
|
types::Rights::empty() |
|
|
types::Rights::empty() |
|
|
} |
|
|
} |
|
|