62 lines
1.2 KiB
C
Executable File
62 lines
1.2 KiB
C
Executable File
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "morphos.h"
|
|
#define MAX_DOS_NAME FILENAME_MAX
|
|
|
|
static char *getFullPath(const char *path)
|
|
{
|
|
char *appPath = malloc(sizeof(char) * MAX_DOS_NAME);
|
|
BPTR pathLock = Lock(path, SHARED_LOCK);
|
|
if (pathLock)
|
|
{
|
|
NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME);
|
|
UnLock(pathLock);
|
|
|
|
return appPath;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static char *getCurrentPath(void)
|
|
{
|
|
char *appPath = malloc(sizeof(char) * MAX_DOS_NAME);
|
|
BOOL success = GetCurrentDirName(appPath, sizeof(char) * MAX_DOS_NAME);
|
|
if (!success) {
|
|
strncpy(appPath, "PROGDIR:", sizeof(char) * MAX_DOS_NAME);
|
|
}
|
|
|
|
return appPath;
|
|
}
|
|
|
|
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);
|
|
|
|
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;
|
|
}
|