Fixed non existing path crashes on OS4
This commit is contained in:
parent
69bd81188b
commit
32eeb07c54
|
@ -23,4 +23,5 @@ lite
|
|||
*.lha
|
||||
release_files
|
||||
*.o
|
||||
*.snalyzerinfo
|
||||
|
||||
|
|
|
@ -195,6 +195,10 @@ https://git.walkero.gr/walkero/lite-xl/issues
|
|||
|
||||
# Changelog
|
||||
|
||||
## [2.0.3r3] - future
|
||||
### Fixed
|
||||
- Fixed non existing path crashes on OS4
|
||||
|
||||
## [2.0.3r2] - 2022-06-18
|
||||
### Added
|
||||
- First public MorphOS version released
|
||||
|
|
|
@ -5,30 +5,29 @@
|
|||
|
||||
#include "amigaos4.h"
|
||||
|
||||
static char *getFullPath(const char *path)
|
||||
static BOOL getFullPath(const char *path, char *result)
|
||||
{
|
||||
char *appPath = malloc(sizeof(char) * MAX_DOS_NAME);
|
||||
BPTR pathLock = Lock(path, SHARED_LOCK);
|
||||
if (pathLock)
|
||||
{
|
||||
NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME);
|
||||
NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME);
|
||||
UnLock(pathLock);
|
||||
|
||||
return appPath;
|
||||
return TRUE;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static char *getCurrentPath(void)
|
||||
static BOOL getCurrentPath(char *result)
|
||||
{
|
||||
char *appPath = malloc(sizeof(char) * MAX_DOS_NAME);
|
||||
BPTR pathLock = GetCurrentDir();
|
||||
if (pathLock)
|
||||
{
|
||||
NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME);
|
||||
return appPath;
|
||||
NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME);
|
||||
return TRUE;
|
||||
}
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *_fullpath(const char *path)
|
||||
|
@ -46,16 +45,25 @@ char *_fullpath(const char *path)
|
|||
if (!strcmp(path, "./lite"))
|
||||
{
|
||||
// TODO: Add code to get the name of the executable
|
||||
strcpy(result, getFullPath("PROGDIR:lite"));
|
||||
return result;
|
||||
if (getFullPath("PROGDIR:lite", result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(path, "."))
|
||||
{
|
||||
strcpy(result, getCurrentPath());
|
||||
return result;
|
||||
if(getCurrentPath(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(result, getFullPath(path));
|
||||
return result;
|
||||
if (getFullPath(path, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue