diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index 38e12cb..0c8d005 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -67,12 +67,14 @@ RB_METHOD(nikoStart) std::string journal; // Get current path - getcwd(path, sizeof(path)); + if (getcwd(path, sizeof(path)) == NULL) { + return Qnil; + } #ifdef OS_OSX - journal = std::string(path) + std::string("/_______.app/Contents/MacOS/_______"); + journal = std::string(path) + "/_______.app/Contents/MacOS/_______"; #else - journal = std::string(path) + std::string("/_______"); + journal = std::string(path) + "/_______"; #endif // Run the binary @@ -81,24 +83,6 @@ RB_METHOD(nikoStart) execl(journal.c_str(), journal.c_str(), x_str, y_str, (char*)0); exit(1); } - - // ssize_t len = readlink("/proc/self/exe", path, PATH_MAX); - // if (len > 0) { - // // Replace filename - // for (size_t i = len; i > 0; --i) { - // if (path[i-1] == '/') { - // strcpy(path + i, "_______"); - // break; - // } - // } - // // Run the binary - // pid_t pid = fork(); - // if (pid == 0) { - // execl(path, "_______", x_str, y_str, (char*)0); - - // exit(1); - // } - // } #endif return Qnil; } diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 9d143c3..47209dd 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -4,8 +4,6 @@ #include "binding-types.h" #include "config.h" -static bool isCached = false; - #ifdef _WIN32 #include static WCHAR szStyle[8] = {0}; @@ -16,9 +14,11 @@ static bool isCached = false; static DWORD szTileSize = sizeof(szTile) - 1; static bool setStyle = false; static bool setTile = false; + static bool isCached = false; #else #ifdef __APPLE__ #include "mac-desktop.h" + static bool isCached = false; #else #include #include @@ -120,7 +120,7 @@ end: } MacDesktop::ChangeBackground(shState->config().gameFolder + path, ((color >> 16) & 0xFF) / 255.0, ((color >> 8) & 0xFF) / 255.0, ((color) & 0xFF) / 255.0); #else - char gameDir[1024]; + char gameDir[PATH_MAX]; if (getcwd(gameDir, sizeof(gameDir)) != NULL) { std::string gameDirStr(gameDir); std::stringstream hexColor;