diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 17952024..26fa0ff7 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -39,6 +39,9 @@ #include #include +// Experimental C++17 features +#include + #ifdef ENABLE_DXSDK #include #pragma comment(lib, "D3dx9.lib") diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index e6685624..79b59507 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -56,45 +56,19 @@ namespace Utils bool CreateDirectory(std::string dir) { - char opath[MAX_PATH] = { 0 }; - char *p; - size_t len; + return std::experimental::filesystem::create_directories(dir); + } - strncpy_s(opath, dir.data(), sizeof(opath)); - len = strlen(opath); + std::vector ListFiles(std::string dir) + { + std::vector files; - if (opath[len - 1] == L'/') + for (auto& file : std::experimental::filesystem::directory_iterator(dir)) { - opath[len - 1] = L'\0'; + files.push_back(file.path().generic_string()); } - for (p = opath; *p; p++) - { - if (*p == L'/' || *p == L'\\') - { - *p = L'\0'; - - if (_access(opath, 0)) - { - if (_mkdir(opath) == -1) - { - return false; - } - } - - *p = L'\\'; - } - } - - if (_access(opath, 0)) - { - if (_mkdir(opath) == -1) - { - return false; - } - } - - return true; + return files; } } } diff --git a/src/Utils/IO.hpp b/src/Utils/IO.hpp index 817eb7d4..e4ee4262 100644 --- a/src/Utils/IO.hpp +++ b/src/Utils/IO.hpp @@ -6,5 +6,6 @@ namespace Utils void WriteFile(std::string file, std::string data); std::string ReadFile(std::string file); bool CreateDirectory(std::string dir); + std::vector ListFiles(std::string dir); } }