From 86a35fd6684dacb61e07b40e5ecceef65e907a63 Mon Sep 17 00:00:00 2001 From: Karutoh Date: Sun, 4 Aug 2024 02:09:10 -0700 Subject: [PATCH] Added System::GetDirDialog. --- include/ehs/system/BaseSystem.h | 2 ++ include/ehs/system/System_LNX.h | 2 ++ src/system/BaseSystem.cpp | 5 +++++ src/system/System_LNX.cpp | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/include/ehs/system/BaseSystem.h b/include/ehs/system/BaseSystem.h index f044eb9..c3e54ab 100644 --- a/include/ehs/system/BaseSystem.h +++ b/include/ehs/system/BaseSystem.h @@ -11,5 +11,7 @@ namespace ehs static void OpenURI(const Str_8& uri); static Str_8 OpenFileDialog(const Str_8 &dir, const Str_8 &filters); + + static Str_8 GetDirDialog(const Str_8 &dir); }; } \ No newline at end of file diff --git a/include/ehs/system/System_LNX.h b/include/ehs/system/System_LNX.h index 2f8db6a..144019c 100644 --- a/include/ehs/system/System_LNX.h +++ b/include/ehs/system/System_LNX.h @@ -11,5 +11,7 @@ namespace ehs static void OpenURI(const Str_8& uri); static Str_8 OpenFileDialog(const Str_8 &dir, const Str_8 &filters); + + static Str_8 GetDirDialog(const Str_8 &dir); }; } \ No newline at end of file diff --git a/src/system/BaseSystem.cpp b/src/system/BaseSystem.cpp index 2b6a8a7..c963082 100644 --- a/src/system/BaseSystem.cpp +++ b/src/system/BaseSystem.cpp @@ -10,4 +10,9 @@ namespace ehs { return {}; } + + Str_8 BaseSystem::GetDirDialog(const Str_8 &dir) + { + return {}; + } } diff --git a/src/system/System_LNX.cpp b/src/system/System_LNX.cpp index 8ffd8b9..f837345 100644 --- a/src/system/System_LNX.cpp +++ b/src/system/System_LNX.cpp @@ -40,4 +40,22 @@ namespace ehs return result; } + + Str_8 System::GetDirDialog(const Str_8 &dir) + { + FILE *file = popen("kdialog --getexistingdirectory " + dir, "r"); + + Str_8 result; + + char array[128]; + while(fgets(array, sizeof(array), file)) + result.Push(array); + + pclose(file); + + if (result.Size()) + result.Pop(); + + return result; + } }