diff --git a/get_path.c b/get_path.c index eb889cc01f..9c8553a791 100644 --- a/get_path.c +++ b/get_path.c @@ -23,6 +23,11 @@ #include #endif +#ifdef __OS2__ +#define INCL_DOS +#include +#endif + char *get_path(const char *filename){ char *homedir; char *buff; @@ -56,6 +61,25 @@ char *get_path(const char *filename){ exedir[imax]='\0'; homedir = exedir; } +#elif defined(__OS2__) + { + PPIB ppib; + char path[260]; + + // Get process info blocks + DosGetInfoBlocks(NULL, &ppib); + + // Get full path of the executable + DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); + + // Truncate name part including last backslash + *strrchr(path, '\\') = 0; + + // Convert backslash to slash + _fnslashify(path); + + homedir = path; + } #else return NULL; #endif