From d63db08081b0b479197292aa881ae64d2ed69ac6 Mon Sep 17 00:00:00 2001 From: OmniaX-dev Date: Wed, 8 May 2024 12:47:53 +0200 Subject: [PATCH] Added ostd::Utils::getHomeDirPath function to --- build.nr | 2 +- src/ostd/FileSystem.cpp | 13 +++++++++++++ src/ostd/Utils.hpp | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/build.nr b/build.nr index 861c126..7dbf0f4 100644 --- a/build.nr +++ b/build.nr @@ -1 +1 @@ -1854 +1855 diff --git a/src/ostd/FileSystem.cpp b/src/ostd/FileSystem.cpp index ccd5628..d50fe34 100644 --- a/src/ostd/FileSystem.cpp +++ b/src/ostd/FileSystem.cpp @@ -61,5 +61,18 @@ namespace ostd list.push_back(file.path()); return list; } + + ostd::String Utils::getHomeDirPath(void) + { + ostd::String home_path = ""; +#ifdef WINDOWS_OS + home_path = ostd::String(getenv("HOMEDRIVE")) + "\\" + ostd::String(getenv("HOMEPATH")); +#elif defined(LINUX_OS) + home_path = ostd::String(getenv("HOME")); +#else + home_path = "NULL"; +#endif + return home_path; + } } \ No newline at end of file diff --git a/src/ostd/Utils.hpp b/src/ostd/Utils.hpp index 9d95225..16634df 100755 --- a/src/ostd/Utils.hpp +++ b/src/ostd/Utils.hpp @@ -157,6 +157,7 @@ namespace ostd static std::vector listFilesInDirectoryRecursive(const String& directoryPath); static std::vector listDirectoriesInDirectoryRecursive(const String& directoryPath); static std::vector listDirectoryRecursive(const String& directoryPath); + static ostd::String getHomeDirPath(void); //Implemented in static int32_t solveIntegerExpression(const String& expr);