From ef442025fa537688ef677243d8ab5ed7baf1eb79 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 7 Jan 2017 12:08:12 +0100 Subject: [PATCH] fix(battery): File contents comparison Refs #297 --- src/modules/battery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 1bc42452..0ef9033b 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -34,9 +34,9 @@ namespace modules { // Make state reader if (file_util::exists((m_fstate = path_adapter + "online"))) { - m_state_reader = make_unique([=] { return file_util::contents(m_fstate).erase(1) == "1"; }); + m_state_reader = make_unique([=] { return file_util::contents(m_fstate).compare(0, 1, "1") == 0; }); } else if (file_util::exists((m_fstate = path_battery + "status"))) { - m_state_reader = make_unique([=] { return file_util::contents(m_fstate).erase(8) == "Charging"; }); + m_state_reader = make_unique([=] { return file_util::contents(m_fstate).compare(0, 8, "Charging") == 0; }); } else { throw module_error("No suitable way to get current charge state"); }