]> jfr.im git - irc/xchat.git/commitdiff
WIN32: find the plugins directory based on the path to xchat.exe
authorlsitu <redacted>
Sat, 20 Feb 2010 22:37:43 +0000 (22:37 +0000)
committerlsitu <redacted>
Sat, 20 Feb 2010 22:37:43 +0000 (22:37 +0000)
instead of relying on a hardcoded path

git-svn-id: svn://svn.code.sf.net/p/xchat/svn@1397 893a96be-7f27-4fdf-9d1e-6aeec9d3cce1

plugins/perl/perl.c

index 1d1e24aad4772872107a85b80b699c2e5584bd07..6682dc46e22572029f92c8395dddd5c9cec49743 100644 (file)
@@ -86,7 +86,9 @@ static int
 perl_auto_load (void *unused)
 {
        const char *xdir;
+       char *slash = NULL;
        char *sub_dir;
+       int copied = 0;
 
        /* get the dir in local filesystem encoding (what opendir() expects!) */
        xdir = xchat_get_info (ph, "xchatdirfs");
@@ -104,7 +106,15 @@ perl_auto_load (void *unused)
 
 #ifdef WIN32
        /* autoload from  C:\program files\xchat\plugins\ */
-       perl_auto_load_from_path (XCHATLIBDIR"/plugins");
+       sub_dir = malloc (1025 + 9);
+       copied = GetModuleFileName( 0, sub_dir, 1024 );
+       sub_dir[copied] = '\0';
+       slash = strrchr( sub_dir, '\\' );
+       if( slash != NULL ) {
+               *slash = '\0';
+       }
+       perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
+       free (sub_dir);
 #endif
        return 0;
 }