| 174 | } |
| 175 | |
| 176 | void FileStream::write(const void* buffer, size_t len) |
| 177 | { |
| 178 | if (_mode != StreamMode::write) |
| 179 | { |
| 180 | throw Exception::InvalidOperation("Can not write"); |
| 181 | } |
| 182 | if (len == 0) |
| 183 | { |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | const auto bytesWriten = writeFile(buffer, len, _file); |
| 188 | if (bytesWriten != len) |
| 189 | { |
| 190 | throw Exception::RuntimeError("Failed to write data"); |
| 191 | } |
| 192 | |
| 193 | _offset += bytesWriten; |
| 194 | _length = std::max(_length, _offset); |
| 195 | } |
| 196 | } |