cutter/src/Main.cpp

45 lines
835 B
C++
Raw Normal View History

#include "CutterApplication.h"
2017-10-01 19:09:42 +00:00
#include "MainWindow.h"
2017-09-25 12:55:41 +00:00
#ifdef APPIMAGE
2017-10-23 09:37:30 +00:00
#define PREFIX "/tmp/.cutter_usr"
2017-10-23 09:22:15 +00:00
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
2017-10-24 08:18:16 +00:00
void set_appimage_symlink()
2017-10-23 09:22:15 +00:00
{
char *path = realpath("/proc/self/exe", NULL);
char *i = strrchr(path, '/');
*(i + 1) = '\0';
char *dest = strcat(path, "../");
2017-10-23 09:22:15 +00:00
struct stat buf;
if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode))
{
2017-10-23 09:37:30 +00:00
remove(PREFIX);
2017-10-23 09:22:15 +00:00
}
2017-10-23 09:37:30 +00:00
symlink(dest, PREFIX);
2017-10-23 21:54:35 +00:00
printf("'%s' '%s' '%s'\n", path, i, dest);
2017-10-23 09:22:15 +00:00
free(path);
}
#endif
int main(int argc, char *argv[])
{
2017-10-23 09:22:15 +00:00
// Hack to make it work with AppImage
#ifdef APPIMAGE
2017-10-24 08:18:16 +00:00
set_appimage_symlink();
2017-10-23 09:22:15 +00:00
#endif
2018-03-09 16:06:41 +00:00
CutterApplication a(argc, argv);
2017-10-23 09:22:15 +00:00
int ret = a.exec();
#ifdef APPIMAGE
2017-10-23 09:37:30 +00:00
remove(PREFIX);
2017-10-23 09:22:15 +00:00
#endif
return ret;
}