Browse Source

Made HOME optional and added some caching at the _fullpath()

os4-1.16.12-pr255
George Sokianos 6 months ago
parent
commit
14d813cea1
  1. 2
      README_OS4.md
  2. 6
      src/main.c
  3. 25
      src/platform/amigaos4.c

2
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

6
src/main.c

@ -13,6 +13,8 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#elif __amigaos4__
#include "platform/amigaos4.h"
#elif __APPLE__
#include <mach-o/dyld.h>
#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"

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

Loading…
Cancel
Save