]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface.cxx
index 611143e09d66ca6e170a44adb4edd73bcbc05e4b..6c6e0f8f66812db1e601fb2287359c32d78cd6bf 100644 (file)
@@ -5,6 +5,7 @@
 #else // cpPlugins_SYS_WINDOWS
 #  include <dlfcn.h>
 #endif // cpPlugins_SYS_WINDOWS
+#include <cpPlugins_dirent.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::
@@ -73,11 +74,17 @@ LoadPluginFile( const std::string& filename )
 {
   // Open library with its canonical path name
   auto canonical_fn = cpPlugins::PathHelper::CanonicalPath( filename );
+  if( canonical_fn == "" )
+    throw std::runtime_error(
+      std::string( "cpPlugins::Interface: Library \"" ) +
+      filename +
+      std::string( "\" does not exist." )
+      );
   void* hnd = Self::_DLOpen( canonical_fn );
   if( hnd == NULL )
     throw std::runtime_error(
       std::string( "cpPlugins::Interface: Could not load library \"" ) +
-      canonical_fn +
+      filename +
       std::string( "\"" )
       );
 
@@ -128,6 +135,24 @@ LoadPluginFile( const std::string& filename )
     Self::_DLClose( hnd );
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::
+LoadPluginDir( const std::string& dirname )
+{
+#error ACA VOY
+  DIR *dir;
+  struct dirent *ent;
+  if( (dir = opendir ( dirname.c_str( ) ) ) != NULL)
+  {
+    while ((ent = readdir (dir)) != NULL) {
+      printf ("%s\n", ent->d_name);
+    }
+    closedir (dir);
+  } else {
+    std::cerr << "error" << std::endl;
+  }
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::
 UnloadAll( )