Bug 650237 - Allow applications to use a symbolic link to the xulrunner-stub instead of a copy. r=bsmedberg

This commit is contained in:
Mike Hommey 2011-07-01 10:42:28 +02:00
Родитель 7e6f0bf53f
Коммит 21b2d5da33
1 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -263,8 +263,12 @@ main(int argc, char **argv)
// 3) give up // 3) give up
struct stat fileStat; struct stat fileStat;
strncpy(tmpPath, argv[0], sizeof(tmpPath));
if (!realpath(argv[0], iniPath) || stat(iniPath, &fileStat)) { lastSlash = strrchr(tmpPath, '/');
if (lastSlash) {
*lastSlash = 0;
realpath(tmpPath, iniPath);
} else {
const char *path = getenv("PATH"); const char *path = getenv("PATH");
if (!path) if (!path)
return 1; return 1;
@ -277,8 +281,11 @@ main(int argc, char **argv)
char *token = strtok(pathdup, ":"); char *token = strtok(pathdup, ":");
while (token) { while (token) {
sprintf(tmpPath, "%s/%s", token, argv[0]); sprintf(tmpPath, "%s/%s", token, argv[0]);
if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) { if (stat(tmpPath, &fileStat) == 0) {
found = PR_TRUE; found = PR_TRUE;
lastSlash = strrchr(tmpPath, '/');
*lastSlash = 0;
realpath(tmpPath, iniPath);
break; break;
} }
token = strtok(NULL, ":"); token = strtok(NULL, ":");
@ -287,11 +294,15 @@ main(int argc, char **argv)
if (!found) if (!found)
return 1; return 1;
} }
lastSlash = iniPath + strlen(iniPath);
*lastSlash = '/';
#endif #endif
#ifndef XP_UNIX
lastSlash = strrchr(iniPath, PATH_SEPARATOR_CHAR); lastSlash = strrchr(iniPath, PATH_SEPARATOR_CHAR);
if (!lastSlash) if (!lastSlash)
return 1; return 1;
#endif
*(++lastSlash) = '\0'; *(++lastSlash) = '\0';