Use PATH_MAX constant, prevent -Wunused-variable, remove commented out code and needless std::string

This commit is contained in:
KockaAdmiralac 2018-03-13 18:33:23 +01:00
parent 29f8c7123a
commit 36fae187f3
2 changed files with 8 additions and 24 deletions

View file

@ -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;
}

View file

@ -4,8 +4,6 @@
#include "binding-types.h"
#include "config.h"
static bool isCached = false;
#ifdef _WIN32
#include <windows.h>
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 <giomm/settings.h>
#include <unistd.h>
@ -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;