2022-01-12 00:32:45 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2023-01-29 13:58:56 +01:00
|
|
|
|
|
|
|
#if defined(PROFYLER)
|
2022-09-26 16:30:42 +02:00
|
|
|
#include <profyle.h>
|
2023-01-29 13:58:56 +01:00
|
|
|
#endif
|
2022-01-12 00:32:45 +01:00
|
|
|
|
|
|
|
#include "amigaos4.h"
|
|
|
|
|
2022-08-01 19:08:23 +02:00
|
|
|
static BOOL getFullPath(const char *path, char *result)
|
2022-01-12 00:32:45 +01:00
|
|
|
{
|
|
|
|
BPTR pathLock = Lock(path, SHARED_LOCK);
|
|
|
|
if (pathLock)
|
|
|
|
{
|
2022-08-01 19:08:23 +02:00
|
|
|
NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME);
|
2022-01-12 00:32:45 +01:00
|
|
|
UnLock(pathLock);
|
|
|
|
|
2022-08-01 19:08:23 +02:00
|
|
|
return TRUE;
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
2023-01-29 13:58:56 +01:00
|
|
|
|
2022-08-01 19:08:23 +02:00
|
|
|
return FALSE;
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
|
|
|
|
2022-08-01 19:08:23 +02:00
|
|
|
static BOOL getCurrentPath(char *result)
|
2022-01-12 00:32:45 +01:00
|
|
|
{
|
|
|
|
BPTR pathLock = GetCurrentDir();
|
|
|
|
if (pathLock)
|
|
|
|
{
|
2022-08-01 19:08:23 +02:00
|
|
|
NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME);
|
|
|
|
return TRUE;
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
2022-08-01 19:08:23 +02:00
|
|
|
return FALSE;
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char *_fullpath(const char *path)
|
|
|
|
{
|
|
|
|
static char prvPath[MAX_DOS_NAME];
|
|
|
|
static char result[MAX_DOS_NAME];
|
|
|
|
|
|
|
|
if (!strcmp(path, prvPath))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(prvPath, path);
|
|
|
|
|
2023-01-29 13:58:56 +01:00
|
|
|
if (!strcmp(path, "./lite-xl"))
|
2022-01-12 00:32:45 +01:00
|
|
|
{
|
|
|
|
// TODO: Add code to get the name of the executable
|
2023-01-29 13:58:56 +01:00
|
|
|
if (getFullPath("PROGDIR:lite-xl", result))
|
2022-08-01 19:08:23 +02:00
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(path, "."))
|
|
|
|
{
|
2022-08-01 19:08:23 +02:00
|
|
|
if(getCurrentPath(result))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|
|
|
|
|
2023-01-29 13:58:56 +01:00
|
|
|
if (getFullPath(path, result))
|
2022-08-01 19:08:23 +02:00
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
2023-01-29 13:58:56 +01:00
|
|
|
|
2022-08-01 19:08:23 +02:00
|
|
|
return NULL;
|
2022-01-12 00:32:45 +01:00
|
|
|
}
|