Only try loading driver from disk if the driver name ends with .xmq and is a valid file.

pull/1090/head
Fredrik Öhrström 2023-11-06 20:41:30 +01:00
rodzic 3a097388f5
commit b9306be914
3 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -22,6 +22,9 @@
bool DriverDynamic::load(DriverInfo *di, const string &file)
{
if (!endsWith(file, ".xmq")) return false;
if (!checkFileExists(file.c_str())) return false;
XMQDoc *doc = xmqNewDoc();
bool ok = xmqParseFile(doc, file.c_str(), "config");

Wyświetl plik

@ -2452,3 +2452,8 @@ bool is_lowercase_alnum_text(const char *text)
}
return true;
}
bool endsWith(const std::string& str, const std::string& suffix)
{
return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
}

Wyświetl plik

@ -75,6 +75,7 @@ std::string safeString(std::vector<uchar> &target);
void strprintf(std::string *s, const char* fmt, ...);
std::string tostrprintf(const char* fmt, ...);
std::string tostrprintf(const std::string &fmt, ...);
bool endsWith(const std::string &str, const std::string &suffix);
// Return for example: 2010-03-21
std::string strdate(struct tm *date);