mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
New platform APIs and new OpenAL cmake
This commit is contained in:
@@ -32,8 +32,11 @@ public:
|
||||
void processArgs(std::vector<std::string>& args);
|
||||
bool spawnProcess(const std::string& process, const std::vector<std::string>& args);
|
||||
int getProcessId();
|
||||
bool isProcessRunning(const std::string& name);
|
||||
bool killProcess(const std::string& name);
|
||||
std::string getTempPath();
|
||||
bool copyFile(std::string from, std::string to);
|
||||
bool fileExists(const std::string& file);
|
||||
void openUrl(std::string url);
|
||||
std::string getCPUName();
|
||||
double getTotalSystemMemory();
|
||||
|
@@ -64,6 +64,16 @@ int Platform::getProcessId()
|
||||
return getpid();
|
||||
}
|
||||
|
||||
bool Platform::isProcessRunning(const std::string& name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform::killProcess(const std::string& name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Platform::getTempPath()
|
||||
{
|
||||
return "/tmp/";
|
||||
@@ -74,6 +84,12 @@ 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)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(file.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
void Platform::openUrl(std::string url)
|
||||
{
|
||||
if(url.find("http://") == std::string::npos)
|
||||
|
@@ -61,6 +61,27 @@ int Platform::getProcessId()
|
||||
return GetCurrentProcessId();
|
||||
}
|
||||
|
||||
bool Platform::isProcessRunning(const std::string& name)
|
||||
{
|
||||
if(FindWindowA(name.c_str(), NULL) != NULL)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform::killProcess(const std::string& name)
|
||||
{
|
||||
HWND window = FindWindowA(name.c_str(), NULL);
|
||||
if(window == NULL)
|
||||
return false;
|
||||
DWORD pid = GetProcessId(window);
|
||||
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
|
||||
if(handle == NULL)
|
||||
return false;
|
||||
bool ok = TerminateProcess(handle, 1) != 0;
|
||||
CloseHandle(handle);
|
||||
return ok;
|
||||
}
|
||||
|
||||
std::string Platform::getTempPath()
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
@@ -68,6 +89,13 @@ std::string Platform::getTempPath()
|
||||
return stdext::utf16_to_utf8(path);
|
||||
}
|
||||
|
||||
bool Platform::fileExists(const std::string& file)
|
||||
{
|
||||
std::wstring wfile = stdext::utf8_to_utf16(file);
|
||||
DWORD dwAttrib = GetFileAttributesW(wfile.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
bool Platform::copyFile(std::string from, std::string to)
|
||||
{
|
||||
boost::replace_all(from, "/", "\\");
|
||||
|
Reference in New Issue
Block a user