| 35 | // |
| 36 | |
| 37 | void 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 | |
| 54 | std::shared_ptr<File> Directory::Handle::getChild(const std::string& name) { |
| 55 | // Unlinked directories must be empty, without even "." or ".." |