-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1660: Allow mapdir aliases with starting `/` r=MarkMcCaskey a=MarkMcCaskey Stripping leading `/` is valid because we mount mapped dirs at `/` regardless. Resolves #1503 This solution is a bit hacky, there may be a more elegant solution. I'll look for one tomorrow morning when I'm more mentally fresh. - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io>
- Loading branch information
Showing
7 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
tests/wasi-wast/wasi/snapshot1/mapdir_with_leading_slash.wast
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
;; This file was generated by https://github.com/wasmerio/wasi-tests | ||
|
||
(wasi_test "mapdir_with_leading_slash.wasm" | ||
(map_dirs "/hamlet:test_fs/hamlet") | ||
(assert_return (i64.const 0)) | ||
(assert_stdout "File exists? true\nSCENE III. A room in the castle.\n\n Enter KING CLAUDIUS, ROSENCRANTZ, and GUILDENSTERN \n\nKING CLAUDIUS\n\n I like him not, nor stands it safe with us\n To let his madness range. Therefore prepare you;\n I your commission will forthwith dispatch,\n \n") | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// WASI: | ||
// mapdir: /hamlet:test_fs/hamlet | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
#[cfg(not(target_os = "wasi"))] | ||
let mut base = PathBuf::from("test_fs/hamlet"); | ||
#[cfg(target_os = "wasi")] | ||
let mut base = PathBuf::from("hamlet"); | ||
|
||
base.push("act3/scene3.txt"); | ||
|
||
println!("File exists? {}", base.exists()); | ||
|
||
let mut f = fs::File::open(&base).unwrap(); | ||
let mut s = String::new(); | ||
f.read_to_string(&mut s).unwrap(); | ||
|
||
println!("{}", s.chars().take(256).collect::<String>()); | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
;; This file was generated by https://github.com/wasmerio/wasi-tests | ||
|
||
(wasi_test "mapdir_with_leading_slash.wasm" | ||
(map_dirs "/hamlet:test_fs/hamlet") | ||
(assert_return (i64.const 0)) | ||
(assert_stdout "File exists? true\nSCENE III. A room in the castle.\n\n Enter KING CLAUDIUS, ROSENCRANTZ, and GUILDENSTERN \n\nKING CLAUDIUS\n\n I like him not, nor stands it safe with us\n To let his madness range. Therefore prepare you;\n I your commission will forthwith dispatch,\n \n") | ||
) |