| 257 | } |
| 258 | |
| 259 | String 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 | |
| 280 | void ConfigPackageUtility::SetActiveStageToFile(const String& packageName, const String& stageName) |
| 281 | { |