| 52 | } |
| 53 | |
| 54 | std::shared_ptr<File> Directory::Handle::getChild(const std::string& name) { |
| 55 | // Unlinked directories must be empty, without even "." or ".." |
| 56 | if (!getParent()) { |
| 57 | return nullptr; |
| 58 | } |
| 59 | if (name == ".") { |
| 60 | return file; |
| 61 | } |
| 62 | if (name == "..") { |
| 63 | return getParent(); |
| 64 | } |
| 65 | // Check whether the cache already contains this child. |
| 66 | auto& dcache = getDir()->dcache; |
| 67 | if (auto it = dcache.find(name); it != dcache.end()) { |
| 68 | return it->second.file; |
| 69 | } |
| 70 | // Otherwise check whether the backend contains an underlying file we don't |
| 71 | // know about. |
| 72 | auto child = getDir()->getChild(name); |
| 73 | if (!child) { |
| 74 | return nullptr; |
| 75 | } |
| 76 | cacheChild(name, child, DCacheKind::Normal); |
| 77 | return child; |
| 78 | } |
| 79 | |
| 80 | bool Directory::Handle::mountChild(const std::string& name, |
| 81 | std::shared_ptr<File> child) { |
no test coverage detected