// Directory utilities. This library contains functions for locating configuration directories, for // testing if a command with a given name can be found in the PATH, and various other path-related // issues. #include "config.h" // IWYU pragma: keep #include "path.h" #include #include #include #include #include "common.h" #include "fallback.h" // IWYU pragma: keep #include "wcstringutil.h" #include "wutil.h" // IWYU pragma: keep void append_path_component(wcstring &path, const wcstring &component) { if (path.empty() || component.empty()) { path.append(component); } else { size_t path_len = path.size(); bool path_slash = path.at(path_len - 1) == L'/'; bool comp_slash = component.at(0) == L'/'; if (!path_slash && !comp_slash) { // Need a slash path.push_back(L'/'); } else if (path_slash && comp_slash) { // Too many slashes. path.erase(path_len - 1, 1); } path.append(component); } }