Fixed loading the current folder from terminal using the dot character

This commit is contained in:
George Sokianos 2022-01-03 00:43:04 +00:00
parent 1c3f766e6b
commit c5309e04d6
3 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}