File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
Expand file tree Collapse file tree 3 files changed +13
-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 requires WasmFS to traverse and resolve
25+ // paths (e.g. because it is mounted under a prefix). Returns false if
26+ // paths can be passed through directly to the backend.
27+ virtual bool requiresPathTraversal () { 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,9 @@ class NodeBackend : public Backend {
301303 WASMFS_UNREACHABLE (" TODO: implement NodeBackend::createSymlink" );
302304 }
303305
304- virtual bool isVirtualized () override { return false ; }
306+ virtual bool requiresPathTraversal () override {
307+ return !mountPath.empty ();
308+ }
305309};
306310
307311// TODO: symlink
Original file line number Diff line number Diff line change @@ -71,10 +71,10 @@ 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 does not require path traversal, it can operate on the
75+ // full path directly. In that case, skip WasmFS path parsing and pass the
76+ // path through unchanged .
77+ if (!root->getBackend ()->requiresPathTraversal ()) {
7878 return {std::make_pair (std::move (curr), path)};
7979 }
8080
You can’t perform that action at this time.
0 commit comments