From fdd2f3af333f4aee2e4ef0162f060b37d6a3d074 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Tue, 21 Dec 2021 18:27:25 +0000 Subject: [PATCH] Fixed a forgotten hardcoded path --- .gitignore | 1 + src/main.c | 3 +-- src/platform/amigaos4.c | 54 ++++++++++++++++++----------------------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 229bf0a1..2f72be74 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build* subprojects/lua subprojects/libagg sybprojects/lua +lite diff --git a/src/main.c b/src/main.c index e8e6779f..5ed8c144 100644 --- a/src/main.c +++ b/src/main.c @@ -72,8 +72,7 @@ static void get_exe_filename(char *buf, int sz) { realpath(exepath, buf); #elif __amigaos4__ #include "platform/amigaos4.h" - // TODO: Add code to get the name of the executable - strcpy(buf, _fullpath("PROGDIR:lite")); + strcpy(buf, _fullpath(".")); #else strcpy(buf, "./lite"); #endif diff --git a/src/platform/amigaos4.c b/src/platform/amigaos4.c index 138110a1..9eedba48 100644 --- a/src/platform/amigaos4.c +++ b/src/platform/amigaos4.c @@ -8,41 +8,33 @@ // TODO: check if this is set in SDK #define MAX_PATH_SIZE 255 -char *_fullpath(const char *path) +static char *getFullPath(const char *path) { - //rintf("DBG: _fullpath() %s\n", path); + char *appPath = malloc(sizeof(char) * MAX_PATH_SIZE); - if (strcmp(path, ".")) + BPTR pathLock = Lock(path, SHARED_LOCK); + if (pathLock) { - /* - STRPTR appPath = AllocVecTags(sizeof(char) * MAX_PATH_SIZE, - AVT_Type, MEMF_SHARED, - AVT_ClearWithValue, "\0", - TAG_DONE); - */ - char *appPath = malloc(sizeof(char) * MAX_PATH_SIZE); + NameFromLock(pathLock, appPath, sizeof(char) * MAX_PATH_SIZE); + UnLock(pathLock); - BPTR pathLock = Lock(path, SHARED_LOCK); - if (pathLock) - { - //BPTR parentLock = ParentDir(pathLock); - NameFromLock(pathLock, appPath, sizeof(char) * MAX_PATH_SIZE); - - //printf("DBG: apppath %s\n", appPath); - //UnLock(parentLock); - UnLock(pathLock); - - return appPath; - //return "ram:"; - } - //printf("DBG: pathLock failed\n"); - } - - // TODO: Deal with . path - if (!strcmp(path, ".")) - { - //printf("DBG: return app folder\n"); - return "Applications:Programming/workspace/MyProjects/lite-xl_v1.16.12"; + return appPath; + } + + return NULL; +} + +char *_fullpath(const char *path) +{ + if (strcmp(path, ".")) + { + return getFullPath(path); + } + + if (!strcmp(path, ".")) + { + // TODO: Add code to get the name of the executable + return getFullPath("PROGDIR:lite"); } return NULL;