Skip to content

Commit

Permalink
handle relative paths in the runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej committed Nov 8, 2024
1 parent f9850d5 commit 0dd896f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/wasix/src/syscalls/wasi/path_create_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ pub fn path_create_directory<M: MemorySize>(
let mut path_string = unsafe { get_input_str_ok!(&memory, path, path_len) };
Span::current().record("path", path_string.as_str());

// Convert relative paths into absolute paths
if path_string.starts_with("./") {
path_string = ctx.data().state.fs.relative_path_to_absolute(path_string);
trace!(
%path_string
);
let path = PathBuf::from(&path_string);

if path.is_relative() {
let cur_dir = PathBuf::from(ctx.data().state.fs.current_dir.lock().unwrap().deref());
path_string = cur_dir.join(path).to_str().unwrap().to_owned();
}

wasi_try_ok!(path_create_directory_internal(&mut ctx, fd, &path_string));
Expand Down

0 comments on commit 0dd896f

Please sign in to comment.