| 22 | { |
| 23 | return _inited; |
| 24 | } |
| 25 | |
| 26 | void WinDurango::Init(std::shared_ptr<interfaces::storage::Directory> root) |
| 27 | { |
| 28 | if (this->_inited) |
| 29 | { |
| 30 | return; |
| 31 | } |
| 32 | try |
| 33 | { |
| 34 | rootDir = root; |
| 35 | rootDir->open(); |
| 36 | |
| 37 | std::time_t timestamp = std::time(nullptr); |
| 38 | std::tm datetm = *std::localtime(×tamp); |
| 39 | |
| 40 | char buf[512]; |
| 41 | std::strftime(buf, sizeof(buf), "%d.%m.%Y", &datetm); |
| 42 | |
| 43 | std::string date(buf); |
| 44 | WinDurangoRoot = rootDir->CreateFolder("WinDurango"); |
| 45 | WinDurangoRoot->open(); |
| 46 | |
| 47 | std::shared_ptr<interfaces::storage::File> LogFile = |
| 48 | WinDurangoRoot->CreateFile("windurango_log_" + date + ".log"); |
| 49 | |
| 50 | config = Config(WinDurangoRoot); |
| 51 | log = Logging(LogFile); |
| 52 | |
| 53 | config.parse(); |
| 54 | log.Initialize(); |
| 55 | |
| 56 | this->_inited = true; |
| 57 | } |
| 58 | catch (const std::exception &e) |
| 59 | { |
| 60 | std::cout << "[WinDurango::Common::WinDurango.exception] - Critical: " << e.what() << "\n"; |
| 61 | } |
| 62 | catch (...) |
| 63 | { |
| 64 | std::cout << "[WinDurango::Common::WinDurango.(...))] - Critical: Unknown Error\n"; |
| 65 | } |
| 66 | } |
| 67 | } // namespace wd::common |
no test coverage detected