Skip to content

Commit

Permalink
Resolve relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
azubieta committed Aug 20, 2019
1 parent 7ecdf17 commit 103e1ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/launcher/runtimes/type1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Partly borrowed from

#include <ctype.h>
#include <time.h>
#include <stdlib.h>

#include "md5.h"
#include "appimagelauncher_interface.h"
Expand Down Expand Up @@ -208,6 +209,10 @@ main(int argc, char* argv[], char** envp) {
exit(1);
}

strcpy(appimage_path, realpath(argv[1], NULL));
strcpy(argv0_path, appimage_path);
argv[1] = appimage_path;

int envp_size = 0;
for (char** envp_itr = envp; *envp_itr != NULL; ++envp_itr)
envp_size++;
Expand All @@ -218,16 +223,13 @@ main(int argc, char* argv[], char** envp) {


// Allow to hook up an integration assistant.
if (shouldIntegrationAssistantBeUsedOn(argv[1]) &&
if (shouldIntegrationAssistantBeUsedOn(appimage_path) &&
tryForwardExecToIntegrationAssistant(argc, argv, envp_copy) == 0) {
// A '0' return value means that the assistant took care of the execution therefore we can safely exit
fprintf(stdout, "AppImage execution was handled by the integration assistant\n");
return 0;
}


strcpy(appimage_path, argv[1]);
strcpy(argv0_path, argv[1]);
setenv("TARGET_APPIMAGE", appimage_path, 1);
setenv("DESKTOPINTEGRATION", "false", 1);

Expand Down
8 changes: 5 additions & 3 deletions src/launcher/runtimes/type2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ int main(int argc, char** argv, char** envp) {
exit(1);
}

strcpy(appimage_path, realpath(argv[1], NULL));
strcpy(argv0_path, appimage_path);
argv[1] = appimage_path;

int envp_size = 0;
for (char** envp_itr = envp; *envp_itr != NULL; ++envp_itr)
envp_size++;
Expand All @@ -536,15 +540,13 @@ int main(int argc, char** argv, char** envp) {


// Allow to hook up an integration assistant.
if (shouldIntegrationAssistantBeUsedOn(argv[1]) &&
if (shouldIntegrationAssistantBeUsedOn(appimage_path) &&
tryForwardExecToIntegrationAssistant(argc, argv, envp_copy) == 0) {
// A '0' return value means that the assistant took care of the execution therefore we can safely exit
fprintf(stdout, "AppImage execution was handled by the integration assistant\n");
return 0;
}

strcpy(appimage_path, argv[1]);
strcpy(argv0_path, argv[1]);
setenv("TARGET_APPIMAGE", appimage_path, 1);
setenv("DESKTOPINTEGRATION", "false", 1);

Expand Down

0 comments on commit 103e1ef

Please sign in to comment.