| 420 | #endif |
| 421 | |
| 422 | void init_logs(MainStruct& mS) { |
| 423 | char* homePathSDL = SDL_GetCurrentDirectory(); |
| 424 | mS.homePath = std::filesystem::path(homePathSDL); |
| 425 | SDL_free(homePathSDL); |
| 426 | #ifdef CONFIG_NEXT_TO_EXECUTABLE |
| 427 | std::string CONFIG_FOLDER_NAME = "config"; |
| 428 | std::filesystem::create_directory(CONFIG_FOLDER_NAME); |
| 429 | mS.configPath = mS.homePath / CONFIG_FOLDER_NAME; |
| 430 | #else |
| 431 | char* configPathSDL = SDL_GetPrefPath("ErrorAtLine0", "infinipaint"); |
| 432 | mS.configPath = std::filesystem::path(configPathSDL); |
| 433 | SDL_free(configPathSDL); |
| 434 | #endif |
| 435 | mS.logFile = std::ofstream(mS.configPath / "log.txt"); |
| 436 | Logger::get().set_log_function(Logger::LogType::FATAL, [&, mS = &mS](const std::string& text) { |
| 437 | mS->logFile << "[FATAL] " << text << std::endl; |
| 438 | std::cerr << "[FATAL] " << text << std::endl; |
| 439 | mS->logFile.close(); |
| 440 | }); |
| 441 | Logger::get().set_log_function(Logger::LogType::INFO, [&, mS = &mS](const std::string& text) { |
| 442 | mS->logFile << "[INFO] " << text << std::endl; |
| 443 | Logger::get().cross_platform_println("[INFO] " + text); |
| 444 | }); |
| 445 | |
| 446 | Logger::get().log(Logger::LogType::INFO, "Home Path: " + mS.homePath.string()); |
| 447 | Logger::get().log(Logger::LogType::INFO, "Config Path: " + mS.configPath.string()); |
| 448 | } |
| 449 | |
| 450 | SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) { |
| 451 | std::vector<std::filesystem::path> listOfFilesToOpenFromCommand; |
no test coverage detected