diff --git a/src/framework/cmake/FindOpenAL.cmake b/src/framework/cmake/FindOpenAL.cmake index 4b7ed1eb..a66f2573 100644 --- a/src/framework/cmake/FindOpenAL.cmake +++ b/src/framework/cmake/FindOpenAL.cmake @@ -4,7 +4,7 @@ # OPENAL_LIBRARY - the OPENAL library SET(OPENAL_APPLE_PATHS ~/Library/Frameworks /Library/Frameworks) -FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h PATHS ${OPENAL_APPLE_PATHS}) +FIND_PATH(OPENAL_INCLUDE_DIR al.h PATH_SUFFIXES AL OpenAL PATHS ${OPENAL_APPLE_PATHS}) SET(_OPENAL_STATIC_LIBS libOpenAL.a libal.a libopenal.a libOpenAL32.a) SET(_OPENAL_SHARED_LIBS libOpenAL.dll.a libal.dll.a libopenal.dll.a libOpenAL32.dll.a OpenAL al openal OpenAL32) IF(USE_STATIC_LIBS) diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index bef1c519..eebcfab7 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -81,7 +81,10 @@ void Application::registerLuaFunctions() g_lua.registerSingletonClass("g_platform"); g_lua.bindSingletonFunction("g_platform", "spawnProcess", &Platform::spawnProcess, &g_platform); g_lua.bindSingletonFunction("g_platform", "getProcessId", &Platform::getProcessId, &g_platform); + g_lua.bindSingletonFunction("g_platform", "isProcessRunning", &Platform::isProcessRunning, &g_platform); g_lua.bindSingletonFunction("g_platform", "copyFile", &Platform::copyFile, &g_platform); + g_lua.bindSingletonFunction("g_platform", "fileExists", &Platform::fileExists, &g_platform); + g_lua.bindSingletonFunction("g_platform", "killProcess", &Platform::killProcess, &g_platform); g_lua.bindSingletonFunction("g_platform", "getTempPath", &Platform::getTempPath, &g_platform); g_lua.bindSingletonFunction("g_platform", "openUrl", &Platform::openUrl, &g_platform); g_lua.bindSingletonFunction("g_platform", "getCPUName", &Platform::getCPUName, &g_platform); diff --git a/src/framework/platform/platform.h b/src/framework/platform/platform.h index 2c862cfe..c12bf445 100644 --- a/src/framework/platform/platform.h +++ b/src/framework/platform/platform.h @@ -32,8 +32,11 @@ public: void processArgs(std::vector& args); bool spawnProcess(const std::string& process, const std::vector& 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(); diff --git a/src/framework/platform/unixplatform.cpp b/src/framework/platform/unixplatform.cpp index 144837ef..c6f053c4 100644 --- a/src/framework/platform/unixplatform.cpp +++ b/src/framework/platform/unixplatform.cpp @@ -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) diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index 769cb1e8..ef1d4367 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -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, "/", "\\"); diff --git a/src/framework/sound/declarations.h b/src/framework/sound/declarations.h index 5877ef30..c88e62c1 100644 --- a/src/framework/sound/declarations.h +++ b/src/framework/sound/declarations.h @@ -27,8 +27,8 @@ #define AL_LIBTYPE_STATIC -#include -#include +#include +#include class SoundManager; class SoundSource;