| 278 | } |
| 279 | |
| 280 | bool FileSystemMRM::loadFile(const char* path, dyld3::closure::LoadedFileInfo& info, |
| 281 | char realerPath[MAXPATHLEN], void (^error)(const char* format, ...)) const |
| 282 | { |
| 283 | Diagnostics diag; |
| 284 | std::string resolvedPath = symlinkResolver.realPath(diag, path); |
| 285 | if (diag.hasError()) { |
| 286 | diag.verbose("MRM error: %s\n", diag.errorMessage().c_str()); |
| 287 | diag.clearError(); |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | auto it = fileMap.find(resolvedPath); |
| 292 | if (it == fileMap.end()) |
| 293 | return false; |
| 294 | |
| 295 | if (resolvedPath == path) |
| 296 | realerPath[0] = '\0'; |
| 297 | else |
| 298 | memcpy(realerPath, resolvedPath.c_str(), std::min((size_t)MAXPATHLEN, resolvedPath.size() + 1)); |
| 299 | |
| 300 | // The file exists at this exact path. Lets use it! |
| 301 | const FileInfo& fileInfo = files[it->second]; |
| 302 | |
| 303 | info.fileContent = fileInfo.data; |
| 304 | info.fileContentLen = fileInfo.length; |
| 305 | info.sliceOffset = 0; |
| 306 | info.sliceLen = fileInfo.length; |
| 307 | info.isOSBinary = true; |
| 308 | info.inode = fileInfo.inode; |
| 309 | info.mtime = fileInfo.mtime; |
| 310 | info.unload = nullptr; |
| 311 | info.path = path; |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | void FileSystemMRM::unloadFile(const dyld3::closure::LoadedFileInfo& info) const |
| 316 | { |
no test coverage detected