MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GetActiveStageFromFile

Method GetActiveStageFromFile

lib/remote/configpackageutility.cpp:259–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259String ConfigPackageUtility::GetActiveStageFromFile(const String& packageName)
260{
261 /* Lock the transaction, reading this only happens on startup or when something really is broken. */
262 std::unique_lock<std::mutex> lock(GetStaticActiveStageMutex());
263
264 String path = GetPackageDir() + "/" + packageName + "/active-stage";
265
266 std::ifstream fp;
267 fp.open(path.CStr());
268
269 String stage;
270 std::getline(fp, stage.GetData());
271
272 fp.close();
273
274 if (fp.fail())
275 return ""; /* Don't use exceptions here. The caller must deal with empty stages at this point. Happens on initial package creation for example. */
276
277 return stage.Trim();
278}
279
280void ConfigPackageUtility::SetActiveStageToFile(const String& packageName, const String& stageName)
281{

Callers

nothing calls this directly

Calls 3

CStrMethod · 0.80
closeMethod · 0.80
TrimMethod · 0.80

Tested by

no test coverage detected