| 284 | //------------------------------------------------------------------------- |
| 285 | |
| 286 | int |
| 287 | RecMessageWriteToDisk(RecMessage *msg, const char *fpath) |
| 288 | { |
| 289 | int msg_size; |
| 290 | RecHandle h_file; |
| 291 | int bytes_written; |
| 292 | |
| 293 | // Cap the message (e.g. when we read it, o_end should reflect the |
| 294 | // size of the new buffer that we write to disk, not the size of the |
| 295 | // buffer in memory). |
| 296 | msg->o_end = msg->o_write; |
| 297 | |
| 298 | msg_size = sizeof(RecMessageHdr) + (msg->o_write - msg->o_start); |
| 299 | if ((h_file = RecFileOpenW(fpath)) != REC_HANDLE_INVALID) { |
| 300 | if (RecSnapFileWrite(h_file, reinterpret_cast<char *>(msg), msg_size, &bytes_written) == REC_ERR_FAIL) { |
| 301 | RecFileClose(h_file); |
| 302 | return REC_ERR_FAIL; |
| 303 | } |
| 304 | RecFileClose(h_file); |
| 305 | } |
| 306 | |
| 307 | return REC_ERR_OKAY; |
| 308 | } |
no test coverage detected