From c5309e04d62461cce5501b73aeb64eac73a7922a Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Mon, 3 Jan 2022 00:43:04 +0000 Subject: [PATCH] Fixed loading the current folder from terminal using the dot character --- README_OS4.md | 2 ++ src/main.c | 2 +- src/platform/amigaos4.c | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README_OS4.md b/README_OS4.md index 81a41781..28e81cc7 100644 --- a/README_OS4.md +++ b/README_OS4.md @@ -50,6 +50,8 @@ https://git.walkero.gr/walkero/lite-xl/issues ### Fixed - Fixed the assertion error and crash when the window is resized (#2) - Fixed the resolution on fullscreen toggle to be like the workbench (#4) +- Fixed loading the current folder from terminal using the dot, like + `lite .` or without it (#3) ## [1.16.12.4] - 2021-12-31 ### Fixed diff --git a/src/main.c b/src/main.c index 032c83ca..77514cd4 100644 --- a/src/main.c +++ b/src/main.c @@ -73,7 +73,7 @@ static void get_exe_filename(char *buf, int sz) { _NSGetExecutablePath(exepath, &size); realpath(exepath, buf); #elif __amigaos4__ - strcpy(buf, _fullpath(".")); + strcpy(buf, _fullpath("./lite")); #else strcpy(buf, "./lite"); #endif diff --git a/src/platform/amigaos4.c b/src/platform/amigaos4.c index 887db038..fd53bd2f 100644 --- a/src/platform/amigaos4.c +++ b/src/platform/amigaos4.c @@ -8,7 +8,6 @@ static char *getFullPath(const char *path) { char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); - BPTR pathLock = Lock(path, SHARED_LOCK); if (pathLock) { @@ -17,7 +16,18 @@ static char *getFullPath(const char *path) return appPath; } + return NULL; +} +static char *getCurrentPath(void) +{ + char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); + BPTR pathLock = GetCurrentDir(); + if (pathLock) + { + NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME); + return appPath; + } return NULL; } @@ -33,13 +43,19 @@ char *_fullpath(const char *path) strcpy(prvPath, path); - if (!strcmp(path, ".")) + if (!strcmp(path, "./lite")) { // TODO: Add code to get the name of the executable strcpy(result, getFullPath("PROGDIR:lite")); return result; } + if (!strcmp(path, ".")) + { + strcpy(result, getCurrentPath()); + return result; + } + strcpy(result, getFullPath(path)); return result; }