Use std::filesystem in favor of custom module
Reuse some code. Fix a bug in the process.
Resolves openbmc/openbmc#1254
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I3fdbb70d6372f4a3193204bd2c9b6535315a3c70
diff --git a/sensorset.cpp b/sensorset.cpp
index b76cef7..2952775 100644
--- a/sensorset.cpp
+++ b/sensorset.cpp
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <experimental/filesystem>
#include <regex>
#include <iostream>
#include "sensorset.hpp"
-#include "directory.hpp"
#include "hwmon.hpp"
// TODO: Issue#2 - STL regex generates really bloated code. Use POSIX regex
@@ -28,13 +28,13 @@
SensorSet::SensorSet(const std::string& path)
{
- Directory d(path);
- std::string file;
+ namespace fs = std::experimental::filesystem;
- while (d.next(file))
+ for (const auto& file : fs::directory_iterator(path))
{
std::smatch match;
- std::regex_search(file, match, sensors_regex);
+ auto fileName = file.path().filename();
+ std::regex_search(fileName.native(), match, sensors_regex);
if (match.size() != sensor_regex_match_count)
{