Added path_to_plain_ascii for use by driver-ssl

This commit is contained in:
2023-01-23 16:24:40 -05:00
parent fb48329090
commit 470d8a3c78
3 changed files with 37 additions and 8 deletions

View File

@@ -32,6 +32,16 @@ const int INVALID_SOCKET = -1;
struct termios orig_termios;
// OpenSSL requires plain ascii pathnames. Returns empty string
// if the path cannot be converted to plain ascii.
std::string path_to_plain_ascii(const std::filesystem::path &path) {
std::string s = path.native();
for (char c : s) {
if ((c < 1) || (c > 127)) return "";
}
return s;
}
std::string strerror_str(int err) {
char errbuf[256];
return strerror_r(err, errbuf, 256);