Skip to content

Commit

Permalink
Fixed an error and updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahriarSS committed Oct 27, 2020
1 parent a7edf60 commit 23427a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/serio/serio.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ bool _read(const std::string& path, std::basic_string<char>& 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;
Expand All @@ -144,6 +145,7 @@ bool _write(const std::string& path, const std::basic_string<char>& data)
{
std::basic_ofstream<char> 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;
Expand Down

0 comments on commit 23427a5

Please sign in to comment.