Made HOME optional and added some caching at the _fullpath()
This commit is contained in:
parent
2c711138d7
commit
14d813cea1
|
@ -25,7 +25,7 @@ SetEnv SAVE HOME "Sys:home/"
|
||||||
## TODO list
|
## TODO list
|
||||||
- Free lost Gfx memory
|
- 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.
|
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`
|
- Make the application aknowledge of the executable file name. Now it works only with the filename `lite`
|
||||||
- Add Amiga versioning
|
- Add Amiga versioning
|
||||||
- Fix the resolution of the fullscreen mode
|
- Fix the resolution of the fullscreen mode
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
#elif __amigaos4__
|
||||||
|
#include "platform/amigaos4.h"
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +73,6 @@ static void get_exe_filename(char *buf, int sz) {
|
||||||
_NSGetExecutablePath(exepath, &size);
|
_NSGetExecutablePath(exepath, &size);
|
||||||
realpath(exepath, buf);
|
realpath(exepath, buf);
|
||||||
#elif __amigaos4__
|
#elif __amigaos4__
|
||||||
#include "platform/amigaos4.h"
|
|
||||||
strcpy(buf, _fullpath("."));
|
strcpy(buf, _fullpath("."));
|
||||||
#else
|
#else
|
||||||
strcpy(buf, "./lite");
|
strcpy(buf, "./lite");
|
||||||
|
@ -174,6 +175,9 @@ init_lua:
|
||||||
" HOME = os.getenv('" LITE_OS_HOME "')\n"
|
" HOME = os.getenv('" LITE_OS_HOME "')\n"
|
||||||
" local exedir = EXEFILE:match(\"^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$\")\n"
|
" local exedir = EXEFILE:match(\"^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$\")\n"
|
||||||
" local prefix = exedir:match(\"^(.*)" LITE_PATHSEP_PATTERN "bin$\")\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"
|
" dofile((MACOS_RESOURCES or (prefix and prefix .. '/share/lite-xl' or exedir .. '/data')) .. '/core/start.lua')\n"
|
||||||
" core = require('core')\n"
|
" core = require('core')\n"
|
||||||
" core.init()\n"
|
" core.init()\n"
|
||||||
|
|
|
@ -5,17 +5,15 @@
|
||||||
|
|
||||||
#include "amigaos4.h"
|
#include "amigaos4.h"
|
||||||
|
|
||||||
// TODO: check if this is set in SDK
|
|
||||||
#define MAX_PATH_SIZE 255
|
|
||||||
|
|
||||||
static char *getFullPath(const char *path)
|
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);
|
BPTR pathLock = Lock(path, SHARED_LOCK);
|
||||||
if (pathLock)
|
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);
|
UnLock(pathLock);
|
||||||
|
|
||||||
return appPath;
|
return appPath;
|
||||||
|
@ -26,16 +24,25 @@ static char *getFullPath(const char *path)
|
||||||
|
|
||||||
char *_fullpath(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, "."))
|
if (!strcmp(path, "."))
|
||||||
{
|
{
|
||||||
// TODO: Add code to get the name of the executable
|
// 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…
Reference in New Issue