[feat] write and load thumbnails supported

This commit is contained in:
dijunkun
2024-11-07 16:29:02 +08:00
parent e3c2e9ec6d
commit 4c6159e4d4
8 changed files with 300 additions and 123 deletions

View File

@@ -99,4 +99,27 @@ std::string GetMac() {
close(sock);
#endif
return mac_addr;
}
std::string GetHostName() {
char hostname[256];
#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
std::cerr << "WSAStartup failed." << std::endl;
return "";
}
if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR) {
LOG_ERROR("gethostname failed: {}", WSAGetLastError());
WSACleanup();
return "";
}
WSACleanup();
#else
if (gethostname(hostname, sizeof(hostname)) == -1) {
LOG_ERROR("gethostname failed");
return "";
}
#endif
return hostname;
}

View File

@@ -10,5 +10,6 @@
#include <iostream>
std::string GetMac();
std::string GetHostName();
#endif