Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/fs_mem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ export class OpenDirectory extends Fd {
return wasi.ERRNO_PERM;
}

if (inode instanceof Directory) {
inode.parent = parent_entry;
}
parent_entry.contents.set(filename, inode);

return wasi.ERRNO_SUCCESS;
Expand Down Expand Up @@ -557,7 +560,7 @@ class Path {

export class Directory extends Inode {
contents: Map<string, Inode>;
private parent: Directory | null = null;
parent: Directory | null = null;

constructor(contents: Map<string, Inode> | [string, Inode][]) {
super();
Expand Down Expand Up @@ -712,6 +715,7 @@ export class Directory extends Inode {
new_child = new File(new ArrayBuffer(0));
} else {
new_child = new Directory(new Map());
new_child.parent = parent_entry;
}
parent_entry.contents.set(filename, new_child);
entry = new_child;
Expand Down