From 9b1fea5c36f2bed12e76b8d1238411ee2f5f17c2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 16 Jun 2023 16:12:20 -0500 Subject: [PATCH] IGFD: remove std::filesystem support it is unused in Furnace --- extern/igfd/ImGuiFileDialog.cpp | 89 +---------------------------- extern/igfd/ImGuiFileDialog.h | 12 +--- extern/igfd/ImGuiFileDialogConfig.h | 3 - 3 files changed, 3 insertions(+), 101 deletions(-) diff --git a/extern/igfd/ImGuiFileDialog.cpp b/extern/igfd/ImGuiFileDialog.cpp index 4ad01ba1f..b4941c793 100644 --- a/extern/igfd/ImGuiFileDialog.cpp +++ b/extern/igfd/ImGuiFileDialog.cpp @@ -42,10 +42,6 @@ SOFTWARE. #include #include #include -// this option need c++17 -#ifdef USE_STD_FILESYSTEM - #include -#endif #if defined (__EMSCRIPTEN__) // EMSCRIPTEN #include #endif // EMSCRIPTEN @@ -53,12 +49,7 @@ SOFTWARE. #define stat _stat #define stricmp _stricmp #include - // this option need c++17 - #ifdef USE_STD_FILESYSTEM - #include - #else - #include "dirent/dirent.h" // directly open the dirent file attached to this lib - #endif // USE_STD_FILESYSTEM + #include "dirent/dirent.h" // directly open the dirent file attached to this lib #define PATH_SEP '\\' #ifndef PATH_MAX #define PATH_MAX 260 @@ -67,10 +58,7 @@ SOFTWARE. #define UNIX #define stricmp strcasecmp #include - // this option need c++17 - #ifndef USE_STD_FILESYSTEM - #include - #endif // USE_STD_FILESYSTEM + #include #define PATH_SEP '/' #endif // defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) @@ -320,12 +308,10 @@ namespace IGFD //// INLINE FUNCTIONS /////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// -#ifndef USE_STD_FILESYSTEM inline int inAlphaSort(const struct dirent** a, const struct dirent** b) { return strcoll((*a)->d_name, (*b)->d_name); } -#endif ///////////////////////////////////////////////////////////////////////////////////// //// FILE EXTENTIONS INFOS ////////////////////////////////////////////////////////// @@ -497,16 +483,6 @@ namespace IGFD if (!name.empty()) { -#ifdef USE_STD_FILESYSTEM - namespace fs = std::filesystem; -#ifdef WIN32 - std::wstring wname = IGFD::Utils::string_to_wstring(name.c_str()); - fs::path pathName = fs::path(wname); -#else - fs::path pathName = fs::path(name); -#endif - bExists = fs::is_directory(pathName); -#else DIR* pDir = nullptr; pDir = opendir(name.c_str()); if (pDir != nullptr) @@ -514,7 +490,6 @@ namespace IGFD bExists = true; (void)closedir(pDir); } -#endif // USE_STD_FILESYSTEM } return bExists; // this is not a directory! @@ -529,18 +504,11 @@ namespace IGFD if (!IsDirectoryExist(name)) { #ifdef WIN32 -#ifdef USE_STD_FILESYSTEM - namespace fs = std::filesystem; - std::wstring wname = IGFD::Utils::string_to_wstring(name.c_str()); - fs::path pathName = fs::path(wname); - res = fs::create_directory(pathName); -#else std::wstring wname = IGFD::Utils::string_to_wstring(name); if (CreateDirectoryW(wname.c_str(), nullptr)) { res = true; } -#endif // USE_STD_FILESYSTEM #elif defined(__EMSCRIPTEN__) std::string str = std::string("FS.mkdir('") + name + "');"; emscripten_run_script(str.c_str()); @@ -563,26 +531,6 @@ namespace IGFD return res; } -#ifdef USE_STD_FILESYSTEM - // https://github.com/aiekick/ImGuiFileDialog/issues/54 - IGFD::Utils::PathStruct IGFD::Utils::ParsePathFileName(const std::string& vPathFileName) - { - namespace fs = std::filesystem; - PathStruct res; - if (vPathFileName.empty()) - return res; - - auto fsPath = fs::path(vPathFileName); - - if (fs::is_regular_file(fsPath)) { - res.name = fsPath.string(); - res.path = fsPath.parent_path().string(); - res.isOk = true; - } - - return res; - } -#else IGFD::Utils::PathStruct IGFD::Utils::ParsePathFileName(const std::string& vPathFileName) { PathStruct res; @@ -627,7 +575,6 @@ namespace IGFD return res; } -#endif // USE_STD_FILESYSTEM void IGFD::Utils::AppendToBuffer(char* vBuffer, size_t vBufferLen, const std::string& vStr) { std::string st = vStr; @@ -1552,24 +1499,6 @@ namespace IGFD ClearFileLists(); -#ifdef USE_STD_FILESYSTEM - //const auto wpath = IGFD::Utils::WGetString(path.c_str()); - const std::filesystem::path fspath(path); - const auto dir_iter = std::filesystem::directory_iterator(fspath); - AddFile(vFileDialogInternal, path, "..", 'd'); - for (const auto& file : dir_iter) - { - char fileType = 0; - if (file.is_symlink()) - fileType = 'l'; - else if (file.is_directory()) - fileType = 'd'; - else - fileType = 'f'; - auto fileNameExt = file.path().filename().string(); - AddFile(vFileDialogInternal, path, fileNameExt, fileType); - } -#else // dirent struct dirent** files = nullptr; int n = scandir(path.c_str(), &files, nullptr, inAlphaSort); logV("IGFD: %d entries in directory",n); @@ -1643,7 +1572,6 @@ namespace IGFD } else { logV("IGFD: it's empty"); } -#endif // USE_STD_FILESYSTEM logV("IGFD: sorting fields..."); SortFields(vFileDialogInternal, puSortingField, false); @@ -1891,16 +1819,6 @@ namespace IGFD path += std::string(1u, PATH_SEP); #endif // WIN32 -#ifdef USE_STD_FILESYSTEM - namespace fs = std::filesystem; - bool dir_opened = fs::is_directory(vPath); - if (!dir_opened) - { - path = "."; - dir_opened = fs::is_directory(vPath); - } - if (dir_opened) -#else DIR* dir = opendir(path.c_str()); if (dir == nullptr) { @@ -1909,7 +1827,6 @@ namespace IGFD } if (dir != nullptr) -#endif // USE_STD_FILESYSTEM { #ifdef WIN32 DWORD numchar = 0; @@ -1945,9 +1862,7 @@ namespace IGFD #endif // WIN32 } } -#ifndef USE_STD_FILESYSTEM closedir(dir); -#endif } } diff --git a/extern/igfd/ImGuiFileDialog.h b/extern/igfd/ImGuiFileDialog.h index 2ad9cbc82..9c2d246f8 100644 --- a/extern/igfd/ImGuiFileDialog.h +++ b/extern/igfd/ImGuiFileDialog.h @@ -534,23 +534,13 @@ if (IGFD_DisplayDialog(cfiledialog, "filedlg", ImGuiWindowFlags_NoCollapse, minS // destroy ImGuiFileDialog IGFD_Destroy(cfiledialog); ------------------------------------------------------------------------------------------------------------------ -## Std::filesystem (c++17) can be used instead of dirent.h ------------------------------------------------------------------------------------------------------------------ - -you just need to uncomment that in the config file - -#define USE_STD_FILESYSTEM - -in this mode dirent is not more required - ----------------------------------------------------------------------------------------------------------------- ## How to Integrate ImGuiFileDialog in your project ----------------------------------------------------------------------------------------------------------------- ### ImGuiFileDialog require : -* dirent v1.23 (only when USE_STD_FILESYSTEM is not defined) (https://github.com/tronkko/dirent/tree/v1.23) lib, only for windows. Successfully tested with version v1.23 only +* dirent v1.23 (https://github.com/tronkko/dirent/tree/v1.23) lib, only for windows. Successfully tested with version v1.23 only * Dear ImGui (https://github.com/ocornut/imgui/tree/master) (with/without tables widgets) ### Customize ImGuiFileDialog : diff --git a/extern/igfd/ImGuiFileDialogConfig.h b/extern/igfd/ImGuiFileDialogConfig.h index 1db638dda..4a212b600 100644 --- a/extern/igfd/ImGuiFileDialogConfig.h +++ b/extern/igfd/ImGuiFileDialogConfig.h @@ -2,9 +2,6 @@ // uncomment and modify defines under for customize ImGuiFileDialog -//this options need c++17 -//#define USE_STD_FILESYSTEM - //#define MAX_FILE_DIALOG_NAME_BUFFER 1024 //#define MAX_PATH_BUFFER_SIZE 1024