forked from Mirrors/openclonk
linux: Replace Application.Location with readlink("/proc/self/exe")
parent
b4439ac1b7
commit
afe5411709
|
@ -434,8 +434,18 @@ void C4ConfigGeneral::DeterminePaths()
|
|||
TempPath = StdStrBuf(apath);
|
||||
if (TempPath[0]) TempPath.AppendBackslash();
|
||||
#elif defined(__linux__)
|
||||
GetParentPath(Application.Location, &ExePath);
|
||||
ExePath.AppendBackslash();
|
||||
ExePath.SetLength(1024);
|
||||
ssize_t l = readlink("/proc/self/exe", ExePath.getMData(), 1024);
|
||||
if (l < -1)
|
||||
{
|
||||
ExePath.Ref(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
ExePath.SetLength(l);
|
||||
GetParentPath(ExePath.getData(), &ExePath);
|
||||
ExePath.AppendBackslash();
|
||||
}
|
||||
const char * t = getenv("TMPDIR");
|
||||
if (t)
|
||||
{
|
||||
|
|
|
@ -177,7 +177,6 @@ protected:
|
|||
void HandleNSEvent(/*NSEvent*/void* event);
|
||||
StdStrBuf GetGameDataPath();
|
||||
#endif
|
||||
const char * Location;
|
||||
pthread_t MainThread;
|
||||
bool DoNotDelay;
|
||||
bool IsShiftDown() { return KeyMask & MK_SHIFT; }
|
||||
|
|
|
@ -71,7 +71,7 @@ void C4Window::FlashWindow()
|
|||
|
||||
#ifdef USE_COCOA
|
||||
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false), Location(""), DoNotDelay(false), MainThread(pthread_self()), fDspModeSet(false)
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false), DoNotDelay(false), MainThread(pthread_self()), fDspModeSet(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
/* C4AbstractApp */
|
||||
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false),
|
||||
Location(""), DoNotDelay(false), MainThread(pthread_self()), fDspModeSet(false)
|
||||
DoNotDelay(false), MainThread(pthread_self()), fDspModeSet(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,6 @@ bool C4AbstractApp::Init(int argc, char * argv[])
|
|||
// Set locale
|
||||
setlocale(LC_ALL,"");
|
||||
|
||||
// SDLmain.m copied the executable path into argv[0];
|
||||
// just copy it (not sure if original buffer is guaranteed
|
||||
// to be permanent).
|
||||
static char dir[PATH_MAX];
|
||||
SCopy(argv[0], dir);
|
||||
Location = dir;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0)
|
||||
{
|
||||
Log("Error initializing SDL.");
|
||||
|
|
|
@ -48,7 +48,7 @@ static void readline_callback (char *);
|
|||
/* C4AbstractApp */
|
||||
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false),
|
||||
Location(""), DoNotDelay(false),
|
||||
DoNotDelay(false),
|
||||
// main thread
|
||||
#ifdef HAVE_PTHREAD
|
||||
MainThread (pthread_self()),
|
||||
|
@ -67,19 +67,6 @@ bool C4AbstractApp::Init(int argc, char * argv[])
|
|||
{
|
||||
// Set locale
|
||||
setlocale(LC_ALL,"");
|
||||
// Try to figure out the location of the executable
|
||||
static char dir[PATH_MAX];
|
||||
SCopy(argv[0], dir);
|
||||
if (dir[0] != '/')
|
||||
{
|
||||
SInsert(dir, "/");
|
||||
SInsert(dir, GetWorkingDirectory());
|
||||
Location = dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
Location = dir;
|
||||
}
|
||||
|
||||
// Custom initialization
|
||||
return DoInit (argc, argv);
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace
|
|||
|
||||
C4X11AppImpl::WindowListT C4X11AppImpl::WindowList;
|
||||
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false), dpy(0), Location(""),
|
||||
C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false), dpy(0),
|
||||
// main thread
|
||||
#ifdef HAVE_PTHREAD
|
||||
MainThread (pthread_self()),
|
||||
|
@ -112,18 +112,6 @@ bool C4AbstractApp::Init(int argc, char * argv[])
|
|||
#endif
|
||||
// Try to figure out the location of the executable
|
||||
Priv->argc=argc; Priv->argv=argv;
|
||||
static char dir[PATH_MAX];
|
||||
SCopy(argv[0], dir);
|
||||
if (dir[0] != '/')
|
||||
{
|
||||
SInsert(dir, "/");
|
||||
SInsert(dir, GetWorkingDirectory());
|
||||
Location = dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
Location = dir;
|
||||
}
|
||||
|
||||
if (!(dpy = XOpenDisplay (0)))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue