diff --git a/solanaceae/message3/file_rw_file.hpp b/solanaceae/message3/file_rw_file.hpp index 8644cf7..3c6f470 100644 --- a/solanaceae/message3/file_rw_file.hpp +++ b/solanaceae/message3/file_rw_file.hpp @@ -37,13 +37,6 @@ struct FileRWFile : public FileI { // TODO: error check _file.seekg(pos, std::ios::beg); -#if 0 - std::vector chunk; - int read_char; - for (size_t i = 0; i < size && (_file_size == 0 || i+pos < _file_size) && (read_char = _file.get()) != std::ifstream::traits_type::eof(); i++) { - chunk.push_back(read_char); - } -#else std::vector chunk(size); const auto nread = _file.read(reinterpret_cast(chunk.data()), chunk.size()).gcount(); if (nread != std::numeric_limits::max()) { @@ -51,7 +44,6 @@ struct FileRWFile : public FileI { } else { chunk.clear(); } -#endif _bytes_read += chunk.size(); @@ -66,7 +58,9 @@ struct FileRWFile : public FileI { // if out-of-order, seek if (_file.tellp() != int64_t(pos)) { // TODO: error check - _file.seekp(pos, std::ios::beg); + if (_file.seekp(pos, std::ios::beg).fail()) { + return false; + } } _file.write(reinterpret_cast(data.data()), data.size());