From 23427a58189e52d9d33e78a14899bb7c1cf127d9 Mon Sep 17 00:00:00 2001 From: _ Date: Tue, 27 Oct 2020 21:34:15 +0330 Subject: [PATCH] Fixed an error and updated version --- CMakeLists.txt | 2 +- src/serio/serio.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd7f0e..27c88a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.5) -project(Serio VERSION 0.1.0 LANGUAGES CXX) +project(Serio VERSION 0.2.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/src/serio/serio.h b/src/serio/serio.h index 6420ebc..beee6f8 100644 --- a/src/serio/serio.h +++ b/src/serio/serio.h @@ -133,8 +133,9 @@ bool _read(const std::string& path, std::basic_string& data) if (!stream.is_open()) return false; stream.seekg(0, std::ios::end); - data.assign(size_t(stream.tellg()), 0); + auto size = stream.tellg(); stream.seekg(0, std::ios::beg); + data.assign(size_t(size), 0); if (stream.rdbuf()->sgetn(&data.front(), std::streamsize(size)) != size) return false; return true; @@ -144,6 +145,7 @@ bool _write(const std::string& path, const std::basic_string& data) { std::basic_ofstream stream(path, std::ios::binary | std::ios::out); if (!stream.is_open()) return false; + auto size = stream.rdbuf()->sputn(data.data(), data.size()); if (size != std::streamsize(data.size())) return false; return true;