I was trying to launch gigedit from qsampler and it did not work. Linuxsampler did not load the gigedit plugin. After some digging in the source I found that Linuxsampler attempts to check whether the plugin is a regular file. This check fails, because it uses the d_type field of the dirent struct (as returned by readdir()). Apparently this d_type field does not work as expected. The manual of readdir() states that the use of this field is not portable. I'm not a c++ expert, but here is a workaround using lstat(). Note that because of the autowrapping some unintentional linebreaks may have been inserted in the patch below. Cheers, Ronald --- src/plugins/InstrumentEditorFactory.cpp.orig 2007-12-29 18:38:18.000000000 +0100 +++ src/plugins/InstrumentEditorFactory.cpp 2007-12-29 18:36:28.000000000 +0100 @@ -28,6 +28,9 @@ #include <dlfcn.h> #include <errno.h> #include <dirent.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #endif #include <string.h> @@ -185,16 +188,20 @@ return; } for (dirent* pEntry = readdir(hDir); pEntry; pEntry = readdir(hDir)) { - // skip entries that are not regular files - if (pEntry->d_type != DT_REG) continue; String sPath = pEntry->d_name; + // make it a full qualified path + sPath = CONFIG_PLUGIN_DIR + ("/" + sPath); + // skip entries that are not regular files + struct stat sPath_stat; + if (lstat(sPath.c_str(), &sPath_stat) != 0 || + (sPath_stat.st_mode & S_IFMT) != S_IFREG) + continue; + // skip files that are not .so files - if ( + if (sPath.length() < 3 || sPath.substr(sPath.length() - 3) != ".so" && sPath.find(".so.") == String::npos ) continue; - // make it a full qualified path - sPath = CONFIG_PLUGIN_DIR + ("/" + sPath); // load the DLL (the plugins should register themselfes automatically) void* pDLL = dlopen(sPath.c_str(), RTLD_NOW); if (pDLL) LoadedDLLs.push_back(pDLL);
Created attachment 20 [details] fix Here is the patch (again, but without wrapping :-) ).
Yes, you are right. I assumed that field would be available on all recent Linux systems at least. Your patch with lstat() looks fine for Linux and OSX, so I just commited it to CVS. Thanks Ronald!