Fixed PATH_MAX problems on *NIX.

This commit is contained in:
Gunnar Beutner 2012-04-02 19:38:04 +02:00
parent f890f1d42c
commit 24c0c7cb9c
2 changed files with 6 additions and 7 deletions

View File

@ -274,8 +274,8 @@ string Application::GetExeDirectory(void)
return ExePath;
#ifndef _WIN32
char Buf[MAXPATHLEN], Cwd[MAXPATHLEN];
char *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN];
char Cwd[MAXPATHLEN];
char *Buf, *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN];
bool FoundPath;
const char *argv0 = m_Arguments[0].c_str();
@ -319,7 +319,7 @@ string Application::GetExeDirectory(void)
}
}
if (realpath(FullExePath, Buf) == NULL)
if ((Buf = realpath(FullExePath, NULL)) == NULL)
throw exception(/*"realpath() failed"*/);
// remove filename
@ -329,6 +329,8 @@ string Application::GetExeDirectory(void)
*LastSlash = '\0';
ExePath = string(Buf);
free(Buf);
#else /* _WIN32 */
char FullExePath[MAXPATHLEN];

View File

@ -1,6 +1,7 @@
#ifndef UNIX_H
#define UNIX_H
#include <limits.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -19,10 +20,6 @@ void closesocket(SOCKET fd);
#define ioctlsocket ioctl
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif /* PATH_MAX */
#define MAXPATHLEN PATH_MAX
/* default visibility takes care of exported symbols */