mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 15:45:59 +01:00
move absolutePath to MiscFunctions
This commit is contained in:
parent
69d17bf424
commit
f0ad77251b
5 changed files with 28 additions and 28 deletions
|
@ -782,7 +782,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
|
|||
return;
|
||||
}
|
||||
|
||||
auto value = absolutePath(rawpath);
|
||||
auto value = absolutePath(rawpath, configCurrentPath);
|
||||
|
||||
if (!std::filesystem::exists(value)) {
|
||||
Debug::log(ERR, "source= file doesnt exist");
|
||||
|
@ -876,28 +876,6 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
return parseError;
|
||||
}
|
||||
|
||||
std::string CConfigManager::absolutePath(const std::string& rawpath) {
|
||||
auto value = rawpath;
|
||||
|
||||
if (value[0] == '.') {
|
||||
auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/'));
|
||||
|
||||
if (value[1] == '.') {
|
||||
auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
|
||||
value.replace(0, 2, parentDir);
|
||||
} else {
|
||||
value.replace(0, 1, currentDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (value[0] == '~') {
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
value.replace(0, 1, std::string(ENVHOME));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equalsPlace) {
|
||||
auto dollarPlace = line.find_first_of('$', equalsPlace);
|
||||
|
||||
|
|
|
@ -101,12 +101,13 @@ public:
|
|||
void ensureDPMS();
|
||||
|
||||
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
||||
std::string absolutePath(const std::string&);
|
||||
|
||||
void addParseError(const std::string&);
|
||||
|
||||
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
||||
|
||||
std::string configCurrentPath;
|
||||
|
||||
private:
|
||||
std::deque<std::string> configPaths; // stores all the config paths
|
||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
||||
|
@ -116,8 +117,6 @@ private:
|
|||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
|
||||
|
||||
std::string configCurrentPath;
|
||||
|
||||
std::string currentCategory = ""; // For storing the category of the current item
|
||||
|
||||
std::string parseError = ""; // For storing a parse error to display later
|
||||
|
|
|
@ -40,6 +40,28 @@ static const float transforms[][9] = {{
|
|||
},
|
||||
};
|
||||
|
||||
std::string absolutePath(const std::string& rawpath, const std::string& currentPath) {
|
||||
auto value = rawpath;
|
||||
|
||||
if (value[0] == '.') {
|
||||
auto currentDir = currentPath.substr(0, currentPath.find_last_of('/'));
|
||||
|
||||
if (value[1] == '.') {
|
||||
auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
|
||||
value.replace(0, 2, parentDir);
|
||||
} else {
|
||||
value.replace(0, 1, currentDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (value[0] == '~') {
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
value.replace(0, 1, std::string(ENVHOME));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) {
|
||||
ASSERT(pSignal);
|
||||
ASSERT(pListener);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../includes.hpp"
|
||||
|
||||
std::string absolutePath(const std::string&, const std::string&);
|
||||
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
|
||||
void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
|
||||
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
|
||||
|
@ -17,4 +18,4 @@ std::string execAndGet(const char*);
|
|||
|
||||
float getPlusMinusKeywordResult(std::string in, float relative);
|
||||
|
||||
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
|
||||
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
|
||||
|
|
|
@ -568,7 +568,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
|||
xkb_keymap * KEYMAP = NULL;
|
||||
|
||||
if (!FILEPATH.empty()) {
|
||||
auto path = g_pConfigManager->absolutePath(FILEPATH);
|
||||
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
||||
|
|
Loading…
Reference in a new issue