MCPcopy Create free account
hub / github.com/EasyRPG/Player / InitRecording

Method InitRecording

src/input_source.cpp:150–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150bool 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
177void Input::Source::Record() {
178 if (record_log) {

Callers 1

InitMethod · 0.80

Calls 2

OpenOutputStreamMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected