diff --git a/README_OS4.md b/README_OS4.md index f84725e6..b29db3f0 100644 --- a/README_OS4.md +++ b/README_OS4.md @@ -25,7 +25,7 @@ SetEnv SAVE HOME "Sys:home/" ## TODO list - Free lost Gfx memory DONE - Make the keyboard shortcuts work. Now, everything can be done with mouse clicks at the toolbar at the bottom of the file list at the left. -- If `HOME` is not set, set it to program folder on program run, having that as an ENV variable, without saving it (only in ENV:) +DONE - If `HOME` is not set, set it to program folder on program run. - Make the application aknowledge of the executable file name. Now it works only with the filename `lite` - Add Amiga versioning - Fix the resolution of the fullscreen mode diff --git a/src/main.c b/src/main.c index 3594a711..29e5aad7 100644 --- a/src/main.c +++ b/src/main.c @@ -13,6 +13,8 @@ #include #include #include +#elif __amigaos4__ + #include "platform/amigaos4.h" #elif __APPLE__ #include #endif @@ -71,7 +73,6 @@ static void get_exe_filename(char *buf, int sz) { _NSGetExecutablePath(exepath, &size); realpath(exepath, buf); #elif __amigaos4__ - #include "platform/amigaos4.h" strcpy(buf, _fullpath(".")); #else strcpy(buf, "./lite"); @@ -174,6 +175,9 @@ init_lua: " HOME = os.getenv('" LITE_OS_HOME "')\n" " local exedir = EXEFILE:match(\"^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$\")\n" " local prefix = exedir:match(\"^(.*)" LITE_PATHSEP_PATTERN "bin$\")\n" + " if not HOME then\n" + " HOME = exedir\n" + " end\n" " dofile((MACOS_RESOURCES or (prefix and prefix .. '/share/lite-xl' or exedir .. '/data')) .. '/core/start.lua')\n" " core = require('core')\n" " core.init()\n" diff --git a/src/platform/amigaos4.c b/src/platform/amigaos4.c index 9eedba48..b99387bb 100644 --- a/src/platform/amigaos4.c +++ b/src/platform/amigaos4.c @@ -5,17 +5,15 @@ #include "amigaos4.h" -// TODO: check if this is set in SDK -#define MAX_PATH_SIZE 255 - static char *getFullPath(const char *path) { - char *appPath = malloc(sizeof(char) * MAX_PATH_SIZE); + char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); BPTR pathLock = Lock(path, SHARED_LOCK); if (pathLock) { - NameFromLock(pathLock, appPath, sizeof(char) * MAX_PATH_SIZE); + NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME); + // printf("DBG: getFullPath() path: %s\nappPath: %s\n", path, appPath); UnLock(pathLock); return appPath; @@ -26,16 +24,25 @@ static char *getFullPath(const char *path) char *_fullpath(const char *path) { - if (strcmp(path, ".")) + static char prvPath[MAX_DOS_NAME]; + static char result[MAX_DOS_NAME]; + + // printf("DBG: prvPath: %s\npath: %s\nresult:%s\n", prvPath, path, result); + if (!strcmp(path, prvPath)) { - return getFullPath(path); + return result; } + strcpy(prvPath, path); + if (!strcmp(path, ".")) { // TODO: Add code to get the name of the executable - return getFullPath("PROGDIR:lite"); + strcpy(result, getFullPath("PROGDIR:lite")); + // printf("DBG: result:%s\n", result); + return result; } - return NULL; + strcpy(result, getFullPath(path)); + return result; }