feat: min code change linux support

This commit is contained in:
mk
2025-11-03 21:03:17 -03:00
parent 777a006792
commit 8d424b7210
19 changed files with 374 additions and 8 deletions

View File

@@ -9,6 +9,10 @@
#include "Utility.h"
#include "../Crypto/RealmCrypt.h"
#ifdef __linux__
typedef float float_t;
#endif
class ByteBuffer {
public:
ByteBuffer( const std::vector< uint8_t > &data );

View File

@@ -2,9 +2,11 @@
#include <cmath>
#include <string>
#include <cstdint>
#if defined(_WIN32) || defined(WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#endif
#include "Utility.h"
@@ -62,6 +64,7 @@ std::string Util::IPFromAddr( const sockaddr_in &addr )
return {};
}
#if defined(_WIN32) || defined(WIN32)
std::string Util::WideToUTF8( const std::wstring &wstr )
{
if( wstr.empty() ) return {};
@@ -95,3 +98,20 @@ std::wstring Util::UTF8ToWide( const std::string &str )
);
return result;
}
#endif
#ifdef __linux__
std::string Util::WideToUTF8( const std::wstring &wstr )
{
if( wstr.empty() ) return {};
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
return conv.to_bytes(wstr);
}
std::wstring Util::UTF8ToWide( const std::string &str )
{
if( str.empty() ) return {};
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
return conv.from_bytes(str);
}
#endif

View File

@@ -2,7 +2,17 @@
#include <cstdint>
#include <string>
#ifdef __linux__
#include <netinet/in.h>
#include <arpa/inet.h>
#include <codecvt>
#include <locale>
#endif
#if defined(_WIN32) || defined(WIN32)
#include <WinSock2.h>
#endif
namespace Util
{