File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ class Backend {
2121 virtual std::shared_ptr<Directory> createDirectory (mode_t mode) = 0;
2222 virtual std::shared_ptr<Symlink> createSymlink (std::string target) = 0;
2323
24- virtual bool isVirtualized () { return true ; }
24+ // Returns true if this backend is mounted under a path prefix and therefore
25+ // requires path resolution within WasmFS (i.e. paths must be split/traversed).
26+ // Returns false if the backend operates on full paths directly.
27+ virtual bool hasMountPath () { return true ; }
2528
2629 virtual ~Backend () = default ;
2730};
Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ class NodeDirectory : public Directory {
183183
184184private:
185185 std::string getChildPath (const std::string& name) {
186+ // If state.path is empty, this backend represents the real root and paths
187+ // should be passed through unchanged.
186188 if (state.path .empty ()) {
187189 return name;
188190 }
@@ -301,7 +303,7 @@ class NodeBackend : public Backend {
301303 WASMFS_UNREACHABLE (" TODO: implement NodeBackend::createSymlink" );
302304 }
303305
304- virtual bool isVirtualized () override { return false ; }
306+ virtual bool hasMountPath () override { return !mountPath. empty () ; }
305307};
306308
307309// TODO: symlink
Original file line number Diff line number Diff line change @@ -71,10 +71,9 @@ ParsedParent doParseParent(std::string_view path,
7171
7272 auto root = wasmFS.getRootDirectory ();
7373
74- // If the root backend is not virtualized, we assume there is only a single
75- // backend, making parent traversal unnecessary. Simply return the current
76- // directory along with the full path.
77- if (!root->getBackend ()->isVirtualized ()) {
74+ // If the root backend has no mount path, it operates on full paths directly.
75+ // In that case, skip WasmFS path traversal and pass the full path through.
76+ if (!root->getBackend ()->hasMountPath ()) {
7877 return {std::make_pair (std::move (curr), path)};
7978 }
8079
You can’t perform that action at this time.
0 commit comments