changeset 26056:5ce6348b1a6e

On OS/2, fall back on the directory where MPlayer is installed if both MPLAYER_HOME and HOME are not set. patch by KO Myung-Hun, komh chollian net
author diego
date Sun, 24 Feb 2008 12:41:51 +0000
parents d8e46fa37615
children 044b3c830459
files get_path.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/get_path.c	Sun Feb 24 12:40:30 2008 +0000
+++ b/get_path.c	Sun Feb 24 12:41:51 2008 +0000
@@ -23,6 +23,11 @@
 #include <windows.h>
 #endif
 
+#ifdef __OS2__
+#define INCL_DOS
+#include <os2.h>
+#endif
+
 char *get_path(const char *filename){
 	char *homedir;
 	char *buff;
@@ -56,6 +61,25 @@
 		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