| 200 | } |
| 201 | |
| 202 | std::wstring ScriptExtender::MakeLogFilePath(std::wstring const & Type, std::wstring const & Extension) |
| 203 | { |
| 204 | if (config_.LogDirectory.empty()) { |
| 205 | config_.LogDirectory = FromUTF8(GetStaticSymbols().ToPath("/Script Extender Logs", PathRootType::UserProfile)); |
| 206 | } |
| 207 | |
| 208 | if (config_.LogDirectory.empty()) { |
| 209 | return L""; |
| 210 | } |
| 211 | |
| 212 | BOOL created = CreateDirectoryW(config_.LogDirectory.c_str(), NULL); |
| 213 | if (created == FALSE) { |
| 214 | DWORD lastError = GetLastError(); |
| 215 | if (lastError != ERROR_ALREADY_EXISTS) { |
| 216 | std::wstringstream err; |
| 217 | err << L"Could not create log directory '" << config_.LogDirectory << "': Error " << lastError; |
| 218 | return L""; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | auto now = std::chrono::system_clock::now(); |
| 223 | auto tt = std::chrono::system_clock::to_time_t(now); |
| 224 | std::tm tm; |
| 225 | gmtime_s(&tm, &tt); |
| 226 | |
| 227 | std::wstringstream ss; |
| 228 | ss << config_.LogDirectory << L"\\" |
| 229 | << Type << L" " |
| 230 | << std::setfill(L'0') |
| 231 | << (tm.tm_year + 1900) << L"-" |
| 232 | << std::setw(2) << (tm.tm_mon + 1) << L"-" |
| 233 | << std::setw(2) << tm.tm_mday << L" " |
| 234 | << std::setw(2) << tm.tm_hour << L"-" |
| 235 | << std::setw(2) << tm.tm_min << L"-" |
| 236 | << std::setw(2) << tm.tm_sec << L"." << Extension; |
| 237 | return ss.str(); |
| 238 | } |
| 239 | |
| 240 | void ScriptExtender::OnStatsLoadGuarded(stats::RPGStats::LoadProc* wrapped, stats::RPGStats* mgr, Array<STDString>* paths) |
| 241 | { |
no test coverage detected