| 148 | |
| 149 | |
| 150 | bool Input::Source::InitRecording(const std::string& record_to_path) { |
| 151 | if (!record_to_path.empty()) { |
| 152 | auto path = record_to_path.c_str(); |
| 153 | |
| 154 | record_log = std::make_unique<Filesystem_Stream::OutputStream>(FileFinder::Root().OpenOutputStream(path, std::ios::out | std::ios::trunc)); |
| 155 | |
| 156 | if (!record_log) { |
| 157 | Output::Error("Failed to open file {} for input recording : {}", path, strerror(errno)); |
| 158 | return false; |
| 159 | } |
| 160 | |
| 161 | *record_log << "H EasyRPG Player Recording\n"; |
| 162 | *record_log << "V 2 " << Version::STRING << "\n"; |
| 163 | |
| 164 | std::time_t t = std::time(nullptr); |
| 165 | // trigraph ?-escapes |
| 166 | std::string date = R"(????-??-?? ??:??:??)"; |
| 167 | char timestr[100]; |
| 168 | if (std::strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", std::localtime(&t))) { |
| 169 | date = std::string(timestr); |
| 170 | } |
| 171 | |
| 172 | *record_log << "D " << date << '\n'; |
| 173 | } |
| 174 | return true; |
| 175 | } |
| 176 | |
| 177 | void Input::Source::Record() { |
| 178 | if (record_log) { |
no test coverage detected