Fixed locale bug with MorphOS
This commit is contained in:
parent
283f1d0837
commit
5d39b4ae68
|
@ -104,6 +104,8 @@ int main(int argc, char **argv) {
|
|||
HINSTANCE lib = LoadLibrary("user32.dll");
|
||||
int (*SetProcessDPIAware)() = (void*) GetProcAddress(lib, "SetProcessDPIAware");
|
||||
SetProcessDPIAware();
|
||||
#elif defined(__morphos__)
|
||||
setlocale(LC_ALL, "");
|
||||
#else
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
|
|
@ -6,29 +6,27 @@
|
|||
#include "morphos.h"
|
||||
#define MAX_DOS_NAME FILENAME_MAX
|
||||
|
||||
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);
|
||||
BOOL success = GetCurrentDirName(appPath, sizeof(char) * MAX_DOS_NAME);
|
||||
BOOL success = GetCurrentDirName(result, sizeof(char) * MAX_DOS_NAME);
|
||||
if (!success) {
|
||||
strncpy(appPath, "PROGDIR:", sizeof(char) * MAX_DOS_NAME);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return appPath;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *_fullpath(const char *path)
|
||||
|
@ -46,16 +44,24 @@ 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());
|
||||
if(getCurrentPath(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (getFullPath(path, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
strcpy(result, getFullPath(path));
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <proto/dos.h>
|
||||
#include <proto/exec.h>
|
||||
#include <locale.h>
|
||||
|
||||
char *_fullpath(const char *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue