Virtual file support (#701)

* Add support for virtual files (eg, not backed by an OS file).

Virtual files are implemented through trait objects, with a default
implementation that tries to behave like on-disk files, but entirely
backed by in-memory structures.

Co-authored-by: Dan Gohman <sunfish@mozilla.com>
This commit is contained in:
iximeow
2020-03-06 11:08:13 -08:00
committed by GitHub
parent 7f7196a655
commit 7e0d9decbf
19 changed files with 1568 additions and 188 deletions

View File

@@ -50,7 +50,7 @@ unsafe fn test_fd_fdstat_set_flags(dir_fd: wasi::Fd) {
)
.expect("reading file"),
buffer.len(),
"shoudl read {} bytes",
"should read {} bytes",
buffer.len()
);
@@ -87,7 +87,7 @@ unsafe fn test_fd_fdstat_set_flags(dir_fd: wasi::Fd) {
)
.expect("reading file"),
buffer.len(),
"shoudl read {} bytes",
"should read {} bytes",
buffer.len()
);
@@ -126,7 +126,7 @@ unsafe fn test_fd_fdstat_set_flags(dir_fd: wasi::Fd) {
)
.expect("reading file"),
buffer.len(),
"shoudl read {} bytes",
"should read {} bytes",
buffer.len()
);

View File

@@ -11,14 +11,14 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) {
wasi::path_create_directory(dir_fd, "dir").expect("creating a directory");
// Test that removing it with a trailing flash succeeds.
// Test that removing it with a trailing slash succeeds.
wasi::path_remove_directory(dir_fd, "dir/")
.expect("remove_directory with a trailing slash on a directory should succeed");
// Create a temporary file.
create_file(dir_fd, "file");
// Test that removing it with no trailing flash fails.
// Test that removing it with no trailing slash fails.
assert_eq!(
wasi::path_remove_directory(dir_fd, "file")
.expect_err("remove_directory without a trailing slash on a file should fail")
@@ -27,7 +27,7 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) {
"errno should be ERRNO_NOTDIR"
);
// Test that removing it with a trailing flash fails.
// Test that removing it with a trailing slash fails.
assert_eq!(
wasi::path_remove_directory(dir_fd, "file/")
.expect_err("remove_directory with a trailing slash on a file should fail")