| 55 | } |
| 56 | |
| 57 | struct FStreamWrapper { |
| 58 | public: |
| 59 | bool Open(const char *path, std::ios::openmode mode) |
| 60 | { |
| 61 | s_.reset(new std::fstream(path, mode)); |
| 62 | return CheckError("new std::fstream(\"%s\", %s)", path, OpenModeToString(mode).c_str()); |
| 63 | } |
| 64 | |
| 65 | void Close() |
| 66 | { |
| 67 | s_ = nullptr; |
| 68 | } |
| 69 | |
| 70 | bool IsOpen() const |
| 71 | { |
| 72 | return s_ != nullptr; |
| 73 | } |
| 74 | |
| 75 | bool seekg(std::streampos pos) |
| 76 | { |
| 77 | s_->seekg(pos); |
| 78 | return CheckError("seekg(%" PRIuMAX ")", static_cast<std::uintmax_t>(pos)); |
| 79 | } |
| 80 | |
| 81 | bool seekg(std::streamoff pos, std::ios::seekdir dir) |
| 82 | { |
| 83 | s_->seekg(pos, dir); |
| 84 | return CheckError("seekg(%" PRIdMAX ", %s)", static_cast<std::intmax_t>(pos), DirToString(dir)); |
| 85 | } |
| 86 | |
| 87 | bool seekp(std::streampos pos) |
| 88 | { |
| 89 | s_->seekp(pos); |
| 90 | return CheckError("seekp(%" PRIuMAX ")", static_cast<std::uintmax_t>(pos)); |
| 91 | } |
| 92 | |
| 93 | bool seekp(std::streamoff pos, std::ios::seekdir dir) |
| 94 | { |
| 95 | s_->seekp(pos, dir); |
| 96 | return CheckError("seekp(%" PRIdMAX ", %s)", static_cast<std::intmax_t>(pos), DirToString(dir)); |
| 97 | } |
| 98 | |
| 99 | bool tellg(std::streampos *result) |
| 100 | { |
| 101 | *result = s_->tellg(); |
| 102 | return CheckError("tellg() = %" PRIuMAX, static_cast<std::uintmax_t>(*result)); |
| 103 | } |
| 104 | |
| 105 | bool tellp(std::streampos *result) |
| 106 | { |
| 107 | *result = s_->tellp(); |
| 108 | return CheckError("tellp() = %" PRIuMAX, static_cast<std::uintmax_t>(*result)); |
| 109 | } |
| 110 | |
| 111 | bool write(const char *data, std::streamsize size) |
| 112 | { |
| 113 | s_->write(data, size); |
| 114 | return CheckError("write(data, %" PRIuMAX ")", static_cast<std::uintmax_t>(size)); |
nothing calls this directly
no outgoing calls
no test coverage detected