switched from linux-dir-api to c++17 dir-api
This commit is contained in:
@@ -9,8 +9,9 @@
|
||||
#include "Obstacle3.h"
|
||||
|
||||
// LINUX ONLY
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
//#include <dirent.h>
|
||||
//#include <stdio.h>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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!";}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user