mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
Platform fixes and rework ping
This commit is contained in:
@@ -37,7 +37,8 @@ public:
|
||||
std::string getTempPath();
|
||||
std::string getCurrentDir();
|
||||
bool copyFile(std::string from, std::string to);
|
||||
bool fileExists(const std::string& file);
|
||||
bool fileExists(std::string file);
|
||||
bool removeFile(std::string file);
|
||||
void openUrl(std::string url);
|
||||
std::string getCPUName();
|
||||
double getTotalSystemMemory();
|
||||
|
@@ -83,8 +83,10 @@ std::string Platform::getCurrentDir()
|
||||
{
|
||||
std::string res;
|
||||
char cwd[2048];
|
||||
if(getcwd(cwd, sizeof(cwd)) != NULL)
|
||||
if(getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
res = cwd;
|
||||
res += "/";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -93,12 +95,19 @@ bool Platform::copyFile(std::string from, std::string to)
|
||||
return system(stdext::format("/bin/cp '%s' '%s'", from, to).c_str()) == 0;
|
||||
}
|
||||
|
||||
bool Platform::fileExists(const std::string& file)
|
||||
bool Platform::fileExists(std::string file)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(file.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
bool Platform::removeFile(std::string file)
|
||||
{
|
||||
if(unlink(file.c_str()) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Platform::openUrl(std::string url)
|
||||
{
|
||||
if(url.find("http://") == std::string::npos)
|
||||
|
@@ -95,11 +95,13 @@ std::string Platform::getCurrentDir()
|
||||
GetCurrentDirectoryW(MAX_PATH, path);
|
||||
ret = stdext::utf16_to_utf8(path);
|
||||
boost::replace_all(ret, "\\", "/");
|
||||
ret += "/";
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Platform::fileExists(const std::string& file)
|
||||
bool Platform::fileExists(std::string file)
|
||||
{
|
||||
boost::replace_all(file, "/", "\\");
|
||||
std::wstring wfile = stdext::utf8_to_utf16(file);
|
||||
DWORD dwAttrib = GetFileAttributesW(wfile.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
@@ -114,6 +116,14 @@ bool Platform::copyFile(std::string from, std::string to)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Platform::removeFile(std::string file)
|
||||
{
|
||||
boost::replace_all(file, "/", "\\");
|
||||
if(DeleteFileW(stdext::utf8_to_utf16(file).c_str()) == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Platform::openUrl(std::string url)
|
||||
{
|
||||
if(url.find("http://") == std::string::npos)
|
||||
|
@@ -590,8 +590,12 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||
}
|
||||
case WM_ACTIVATE: {
|
||||
m_focused = !(wParam == WA_INACTIVE);
|
||||
if(!m_focused)
|
||||
releaseAllKeys();
|
||||
releaseAllKeys();
|
||||
break;
|
||||
}
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS: {
|
||||
releaseAllKeys();
|
||||
break;
|
||||
}
|
||||
case WM_CHAR: {
|
||||
|
Reference in New Issue
Block a user