From 705763f03caa899aa03851d716f9445c3036d891 Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Tue, 27 Mar 2018 12:39:48 +0200 Subject: [PATCH] switched from linux-dir-api to c++17 dir-api --- wifi/estimate/ray3/OBJPool.h | 26 +++++++++++++++++--------- wifi/estimate/ray3/OBJReader.h | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/wifi/estimate/ray3/OBJPool.h b/wifi/estimate/ray3/OBJPool.h index c8eea61..d76edaf 100644 --- a/wifi/estimate/ray3/OBJPool.h +++ b/wifi/estimate/ray3/OBJPool.h @@ -9,8 +9,9 @@ #include "Obstacle3.h" // LINUX ONLY -#include -#include +//#include +//#include +#include namespace Ray3D { @@ -42,19 +43,26 @@ namespace Ray3D { initDone = true; // LINUX ONLY! - DIR* d = opendir(folder.c_str()); - if (!d) {throw Exception("OBJPool: folder not found: " + folder);} + //DIR* d = opendir(folder.c_str()); + //if (!d) {throw Exception("OBJPool: folder not found: " + folder);} + std::experimental::filesystem::path d(folder); + if (!std::experimental::filesystem::exists(d)) { + throw Exception("OBJPool: folder not found: " + folder); + } - struct dirent *dir; - while ((dir = readdir(d)) != NULL) { - const std::string absFile = folder + "/" + dir->d_name; + //struct dirent *dir; + //while ((dir = readdir(d)) != NULL) { + for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(d)) { + //const std::string absFile = folder + "/" + dir->d_name; + const std::string absFile = entry.path().native(); if (endsWith(absFile, ".obj")) { - std::string name = std::string(dir->d_name); + //std::string name = std::string(dir->d_name); + std::string name = entry.path().filename(); name = name.substr(0, name.length() - 4); // without extension load(absFile, name); } } - closedir(d); + //closedir(d); } diff --git a/wifi/estimate/ray3/OBJReader.h b/wifi/estimate/ray3/OBJReader.h index c5b7316..a08a804 100644 --- a/wifi/estimate/ray3/OBJReader.h +++ b/wifi/estimate/ray3/OBJReader.h @@ -160,7 +160,7 @@ private: } // sanity check - if (numVertices != 3) {throw "this face is not a triangle!";} +// if (numVertices != 3) {throw "this face is not a triangle!";} }