diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-11 21:35:37 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-13 13:13:01 +0200 |
commit | 77ed51898157d99112be7550471ec06e32344c9e (patch) | |
tree | 0645274d0f13b4fa6940d4054f74a070611a8ef0 /src/Storage.cpp | |
parent | da89ec98fb34757f0c46dc8cb2dd87ae78d317ce (diff) |
Refactor plugin into seperate pages
TODO: Readd 4chan login page, manganelo creators page, autocomplete
Diffstat (limited to 'src/Storage.cpp')
-rw-r--r-- | src/Storage.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Storage.cpp b/src/Storage.cpp index cd34b56..c9dfb17 100644 --- a/src/Storage.cpp +++ b/src/Storage.cpp @@ -1,9 +1,11 @@ #include "../include/Storage.hpp" #include "../include/env.hpp" +#include "../include/StringUtils.hpp" #include <stdio.h> #include <assert.h> #include <json/reader.h> #include <json/writer.h> +#include <unordered_set> #if OS_FAMILY == OS_FAMILY_POSIX #include <pwd.h> @@ -223,4 +225,23 @@ namespace QuickMedia { return true; } + + bool is_program_executable_by_name(const char *name) { + // TODO: Implement for Windows. Windows also uses semicolon instead of colon as a separator + char *env = getenv("PATH"); + std::unordered_set<std::string> paths; + string_split(env, ':', [&paths](const char *str, size_t size) { + paths.insert(std::string(str, size)); + return true; + }); + + for(const std::string &path_str : paths) { + Path path(path_str); + path.join(name); + if(get_file_type(path) == FileType::REGULAR) + return true; + } + + return false; + } }
\ No newline at end of file |