MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / cacheChild

Method cacheChild

system/lib/wasmfs/file.cpp:37–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35//
36
37void Directory::Handle::cacheChild(const std::string& name,
38 std::shared_ptr<File> child,
39 DCacheKind kind) {
40 // Update the dcache if the backend hasn't opted out of using the dcache or if
41 // this is a mount point, in which case it is not under the control of the
42 // backend.
43 if (kind == DCacheKind::Mount || !getDir()->maintainsFileIdentity()) {
44 auto& dcache = getDir()->dcache;
45 [[maybe_unused]] auto [_, inserted] = dcache.insert({name, {kind, child}});
46 assert(inserted && "inserted child already existed!");
47 }
48 // Set the child's parent.
49 assert(child->locked().getParent() == nullptr ||
50 child->locked().getParent() == getDir());
51 child->locked().setParent(getDir());
52}
53
54std::shared_ptr<File> Directory::Handle::getChild(const std::string& name) {
55 // Unlinked directories must be empty, without even "." or ".."

Callers

nothing calls this directly

Calls 6

getParentMethod · 0.80
setParentMethod · 0.80
assertFunction · 0.50
maintainsFileIdentityMethod · 0.45
insertMethod · 0.45
lockedMethod · 0.45

Tested by

no test coverage detected