mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-11-17 02:35:58 +01:00
Path: use vec instead of set
This commit is contained in:
parent
01f69fab15
commit
5486995a00
1 changed files with 11 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
#include <hyprutils/string/VarList.hpp>
|
#include <hyprutils/string/VarList.hpp>
|
||||||
#include <hyprutils/debug/Log.hpp>
|
#include <hyprutils/debug/Log.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <set>
|
#include <vector>
|
||||||
|
|
||||||
using namespace Hyprutils;
|
using namespace Hyprutils;
|
||||||
|
|
||||||
|
@ -11,6 +11,11 @@ namespace Hyprutils::Path {
|
||||||
return basePath + "/hypr/" + programName + ".conf";
|
return basePath + "/hypr/" + programName + ".conf";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void push_if_new(std::vector<std::string> vec, std::string str) {
|
||||||
|
if (std::find(vec.begin(), vec.end(), str) == vec.end())
|
||||||
|
vec.push_back(str);
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<std::string> getHome() {
|
std::optional<std::string> getHome() {
|
||||||
static const auto homeDir = getenv("HOME");
|
static const auto homeDir = getenv("HOME");
|
||||||
|
|
||||||
|
@ -49,23 +54,23 @@ namespace Hyprutils::Path {
|
||||||
using T = std::optional<std::string>;
|
using T = std::optional<std::string>;
|
||||||
std::pair<T, T> findConfig(std::string programName) {
|
std::pair<T, T> findConfig(std::string programName) {
|
||||||
std::string configPath;
|
std::string configPath;
|
||||||
std::set<std::string> paths;
|
std::vector<std::string> paths;
|
||||||
|
|
||||||
static const auto xdgConfigHome = getXdgConfigHome();
|
static const auto xdgConfigHome = getXdgConfigHome();
|
||||||
if (xdgConfigHome.has_value())
|
if (xdgConfigHome.has_value())
|
||||||
paths.insert(xdgConfigHome.value());
|
push_if_new(paths, xdgConfigHome.value());
|
||||||
|
|
||||||
static const auto home = getHome();
|
static const auto home = getHome();
|
||||||
if (home.has_value())
|
if (home.has_value())
|
||||||
paths.insert(home.value());
|
push_if_new(paths, home.value());
|
||||||
|
|
||||||
static const auto xdgConfigDirs = getXdgConfigDirs();
|
static const auto xdgConfigDirs = getXdgConfigDirs();
|
||||||
if (xdgConfigDirs.has_value()) {
|
if (xdgConfigDirs.has_value()) {
|
||||||
for (auto dir : xdgConfigDirs.value())
|
for (auto dir : xdgConfigDirs.value())
|
||||||
paths.insert(dir);
|
push_if_new(paths, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.insert("/etc/xdg");
|
push_if_new(paths, "/etc/xdg");
|
||||||
|
|
||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
configPath = fullConfigPath(path, programName);
|
configPath = fullConfigPath(path, programName);
|
||||||
|
|
Loading…
Reference in a new issue