| 40 | }; |
| 41 | |
| 42 | class ObjectFileWriter { |
| 43 | |
| 44 | const std::string filePath; |
| 45 | const uint32_t recordSize; |
| 46 | const uint32_t recordVersion; |
| 47 | const bool append; |
| 48 | const std::shared_ptr<Lock> lock; |
| 49 | |
| 50 | std::unique_ptr<FILE, FileCloser> file; |
| 51 | uint32_t recordsWritten = 0; |
| 52 | |
| 53 | public: |
| 54 | |
| 55 | ObjectFileWriter(std::string filePath, uint32_t recordSize, uint32_t recordVersion, bool append) : |
| 56 | filePath(std::move(filePath)), |
| 57 | recordSize(recordSize), |
| 58 | recordVersion(recordVersion), |
| 59 | append(append), |
| 60 | lock(getLock(filePath)) |
| 61 | {} |
| 62 | |
| 63 | |
| 64 | ~ObjectFileWriter() { |
| 65 | if (file != nullptr) { |
| 66 | close(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | bool open(); |
| 71 | void close(); |
| 72 | |
| 73 | bool write(void* data); |
| 74 | }; |
| 75 | |
| 76 | } |
no outgoing calls
no test coverage detected