Fix issue 326: Program doesn't find data directory on some linux (attempt. Tested ok on Debian)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1380 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
50791f752b
commit
54317d94ae
@ -51,4 +51,4 @@ void Warning_function(const char *message, const char *filename, int line_number
|
||||
/// some information about the calling function, and then resume silently.
|
||||
/// This is most useful in debugger so you can put a breakpoint on
|
||||
/// ::Warning_function and examine the stack trace.
|
||||
#define Warning(msg) Warning_function(msg, __FILE__,__LINE__,__func__)
|
||||
#define Warning(msg) Warning_function(msg, __FILE__,__LINE__,__func__)
|
||||
|
||||
18
src/setup.c
18
src/setup.c
@ -35,6 +35,9 @@
|
||||
#import <sys/param.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#import <sys/param.h>
|
||||
#elif defined(__linux__)
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "struct.h"
|
||||
@ -77,11 +80,20 @@ void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir)
|
||||
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
strcpy(program_dir,"PROGDIR:");
|
||||
|
||||
// Linux: argv[0] unreliable
|
||||
#elif defined(__linux__)
|
||||
if (argv0[0]!='/')
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
readlink("/proc/self/exe", path, sizeof(path));
|
||||
Extract_path(program_dir, path);
|
||||
return;
|
||||
}
|
||||
Extract_path(program_dir, argv0);
|
||||
|
||||
// Others: The part of argv[0] before the executable name.
|
||||
// Keep the last \ or /.
|
||||
// Note that on Unix, once installed, the executable is called from a shell
|
||||
// script sitting in /usr/local/bin/, this allows argv[0] to contain the full
|
||||
// path. On Windows, Mingw32 already provides the full path in all cases.
|
||||
// On Windows, Mingw32 already provides the full path in all cases.
|
||||
#else
|
||||
Extract_path(program_dir, argv0);
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user