| 21 | |
| 22 | public: |
| 23 | PIDFile(const std::string& filename) |
| 24 | { |
| 25 | IModuleRegistry& registry = module::GlobalModuleRegistry(); |
| 26 | _filename = registry.getApplicationContext().getSettingsPath() + filename; |
| 27 | |
| 28 | FILE* pid = fopen(_filename.c_str(), "r"); |
| 29 | |
| 30 | // Check for an existing radiant.pid file |
| 31 | if (pid != nullptr) |
| 32 | { |
| 33 | fclose(pid); |
| 34 | |
| 35 | removePIDFile(); |
| 36 | |
| 37 | #ifndef _DEBUG |
| 38 | fs::path path = registry.getApplicationContext().getSettingsPath(); |
| 39 | path /= "darkradiant.log"; |
| 40 | std::string logPath = path.string(); |
| 41 | string::replace_all(logPath, "\\\\", "\\"); |
| 42 | string::replace_all(logPath, "//", "/"); |
| 43 | |
| 44 | std::string msg("Radiant failed to start properly the last time it was run.\n"); |
| 45 | msg += "If this is happening again, you might want to check the log file in\n"; |
| 46 | msg += logPath; |
| 47 | |
| 48 | wxutil::Messagebox box("DarkRadiant - Startup Failure", msg, ui::IDialog::MESSAGE_CONFIRM); |
| 49 | box.run(); |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | // create a primary .pid for global init run |
| 54 | pid = fopen(_filename.c_str(), "w"); |
| 55 | |
| 56 | if (pid) |
| 57 | { |
| 58 | fclose(pid); |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | ~PIDFile() |
| 63 | { |
nothing calls this directly
no test coverage detected