[config] Parse Wine application name without absolute path

pull/93/head
jackun 4 years ago
parent 8b24743a30
commit 6b4103eae9
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -56,7 +56,7 @@ void parseConfigFile() {
while (std::getline(stream, line, '\0'))
{
if (!line.empty()
&& (n = line.find_last_of("/\\")) != std::string::npos
&& ((n = line.find_last_of("/\\")) != std::string::npos)
&& n < line.size() - 1) // have at least one character
{
auto dot = line.find_last_of('.');
@ -65,6 +65,12 @@ void parseConfigFile() {
paths.push_back(env_config + mangohud_dir + "wine-" + line.substr(n + 1, dot - n - 1) + ".conf");
break;
}
else if (ends_with(line, ".exe", true))
{
auto dot = line.find_last_of('.');
paths.push_back(env_config + mangohud_dir + "wine-" + line.substr(0, dot) + ".conf");
break;
}
}
}
}

@ -53,6 +53,22 @@ static bool starts_with(const std::string& s, const char *t) {
return s.rfind(t, 0) == 0;
}
static bool ends_with(const std::string& s, const char *t, bool icase = false) {
std::string s0(s);
std::string s1(t);
if (s0.size() < s1.size())
return false;
if (icase) {
std::transform(s0.begin(), s0.end(), s0.begin(), ::tolower);
std::transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
}
size_t pos = s0.size() - s1.size();
return (s0.rfind(s1, pos) == pos);
}
template<typename T>
static std::string itox(T i) {
std::stringstream ss;

Loading…
Cancel
Save