From d5de27f2891850afc6f8c081bfdd6b9fd08f7f8f Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 15 Apr 2012 14:36:11 +0200 Subject: [PATCH] Apple: Fix loading plugins inside bundles. --- src/vio/csync_vio.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/vio/csync_vio.c b/src/vio/csync_vio.c index 8b51270ae..7610b97dc 100644 --- a/src/vio/csync_vio.c +++ b/src/vio/csync_vio.c @@ -41,6 +41,10 @@ #define MODULE_EXTENSION "so" #endif +#ifdef __APPLE__ +#include +#endif + #include "csync_log.h" int csync_vio_init(CSYNC *ctx, const char *module, const char *args) { @@ -73,7 +77,16 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args) { #ifdef __APPLE__ if (lstat(path, &sb) < 0) { SAFE_FREE(path); - if (asprintf(&path, "../Plugins/csync_%s.%s", module, MODULE_EXTENSION) < 0) { + + char path_tmp[1024]; + uint32_t size = sizeof(path_tmp); + if (_NSGetExecutablePath(path_tmp, &size) == 0) + printf("executable path is %s\n", path_tmp); + + char* path2 = NULL; + path2 = c_dirname(path_tmp); + + if (asprintf(&path, "%s/../Plugins/csync_%s.%s", path2, module, MODULE_EXTENSION) < 0) { return -1; } }