| 30 | } |
| 31 | |
| 32 | bool cmCacheManager::LoadCache(std::string const& path, bool internal, |
| 33 | std::set<std::string>& excludes, |
| 34 | std::set<std::string>& includes) |
| 35 | { |
| 36 | std::string cacheFile = cmStrCat(path, "/CMakeCache.txt"); |
| 37 | // clear the old cache, if we are reading in internal values |
| 38 | if (internal) { |
| 39 | this->Cache.clear(); |
| 40 | } |
| 41 | if (!cmSystemTools::FileExists(cacheFile)) { |
| 42 | this->CleanCMakeFiles(path); |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | cmsys::ifstream fin(cacheFile.c_str()); |
| 47 | if (!fin) { |
| 48 | return false; |
| 49 | } |
| 50 | char const* realbuffer; |
| 51 | std::string buffer; |
| 52 | std::string entryKey; |
| 53 | unsigned int lineno = 0; |
| 54 | while (fin) { |
| 55 | // Format is key:type=value |
| 56 | std::string helpString; |
| 57 | CacheEntry e; |
| 58 | cmSystemTools::GetLineFromStream(fin, buffer); |
| 59 | lineno++; |
| 60 | realbuffer = buffer.c_str(); |
| 61 | while (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' || |
| 62 | *realbuffer == '\n') { |
| 63 | if (*realbuffer == '\n') { |
| 64 | lineno++; |
| 65 | } |
| 66 | realbuffer++; |
| 67 | } |
| 68 | // skip blank lines and comment lines |
| 69 | if (realbuffer[0] == '#' || realbuffer[0] == 0) { |
| 70 | continue; |
| 71 | } |
| 72 | while (realbuffer[0] == '/' && realbuffer[1] == '/') { |
| 73 | if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) { |
| 74 | helpString = cmStrCat(std::move(helpString), '\n', &realbuffer[4]); |
| 75 | } else { |
| 76 | helpString = cmStrCat(std::move(helpString), &realbuffer[2]); |
| 77 | } |
| 78 | cmSystemTools::GetLineFromStream(fin, buffer); |
| 79 | lineno++; |
| 80 | realbuffer = buffer.c_str(); |
| 81 | if (!fin) { |
| 82 | continue; |
| 83 | } |
| 84 | } |
| 85 | e.SetProperty("HELPSTRING", helpString); |
| 86 | if (cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) { |
| 87 | if (excludes.find(entryKey) == excludes.end()) { |
| 88 | // Load internal values if internal is set. |
| 89 | // If the entry is not internal to the cache being loaded |
nothing calls this directly
no test coverage detected