| 58 | } |
| 59 | |
| 60 | void FsNode::loadChildren() { |
| 61 | if (!this->hasLoadedChildrenFromFileSystem) { |
| 62 | BOXEDWINE_CRITICAL_SECTION; |
| 63 | if (this->hasLoadedChildrenFromFileSystem) { |
| 64 | return; |
| 65 | } |
| 66 | this->hasLoadedChildrenFromFileSystem = true; |
| 67 | if (this->nativePath.length()) { |
| 68 | std::vector<Platform::ListNodeResult> results; |
| 69 | Platform::listNodes(nativePath, results); |
| 70 | for (auto& n : results) { |
| 71 | BString localPath = this->path; |
| 72 | BString remotePath = this->nativePath.stringByApppendingPath(n.name); |
| 73 | if (!localPath.endsWith("/")) { |
| 74 | localPath += "/"; |
| 75 | } |
| 76 | Fs::remoteNameToLocal(n.name); |
| 77 | localPath+=n.name; |
| 78 | if (localPath.endsWith(EXT_MIXED)) { |
| 79 | localPath.remove(localPath.length() - 6); |
| 80 | } |
| 81 | if (localPath.endsWith(EXT_DOSATTRIB)) { |
| 82 | continue; |
| 83 | } |
| 84 | if (!localPath.endsWith(EXT_LINK)) { |
| 85 | Fs::addFileNode(localPath, B(""), remotePath, n.isDirectory, shared_from_this()); |
| 86 | } else { |
| 87 | U8 tmp[MAX_FILEPATH_LEN]; |
| 88 | U32 result = Fs::readNativeFile(remotePath, tmp, MAX_FILEPATH_LEN-1); |
| 89 | tmp[result]=0; |
| 90 | if (result==0) { |
| 91 | kwarn_fmt("Could not read link file from filesystem: %s", localPath.c_str()); |
| 92 | } |
| 93 | localPath = localPath.substr(0, localPath.length()-5); |
| 94 | Fs::addFileNode(localPath, BString::copy((const char*)tmp), remotePath, n.isDirectory, shared_from_this()); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | std::shared_ptr<FsNode> FsNode::getChildByName(BString name) { |
no test coverage detected