Members of fedem::dso::DSOLoader.

loadAll

static void loadAll( std::string const& extension );                                // (1) cwd
static void loadAll( std::string const& extension, std::string const& folder );     // (2)
static void loadAll( std::string const& extension,
                     std::vector<std::string> const& list );                         // (3)

Scans a directory non-recursively, and for each regular file or symlink whose name:

  • ends with extension (e.g. ".so"), and
  • starts with the current prefix(), if one is set,

calls load on it.

  1. Scans the current working directory.
  2. Scans folder.
  3. Scans each directory in list.

Files that fail to load are collected. After attempting all of them, if any failed, loadAll throws fedem::exception::FileNotFound naming the failures. A directory that does not exist is skipped silently.

loadAllByEnvironment

static void loadAllByEnvironment( std::string const& extension );                    // (1)
static void loadAllByEnvironment( std::string const& extension,
                                  std::string const& env );                          // (2)

Reads the environment variable, splits it on the platform path separator (:, or ; on Cygwin), and runs loadAll( extension, dir ) for each entry.

  1. Uses the platform's library-path variable — LD_LIBRARY_PATH (Linux), LIBPATH (AIX), SHLIB (HP-UX), PATH (Cygwin).
  2. Uses the variable named by env.

An unset or empty variable is a no-op.

Parameters

NameDescription
extensionSuffix to match, dot included — ".so", ".ffs".
folder / listDirectory or directories to scan.
envName of the environment variable to read for directories.

Examples

DSOLoader::prefix( "lib" );

DSOLoader::loadAll( ".so", "/opt/app/plugins" );                 // /opt/app/plugins/lib*.so
DSOLoader::loadAll( ".so", { "/opt/app/plugins", "./plugins" } );

DSOLoader::loadAllByEnvironment( ".so", "APP_PLUGIN_PATH" );     // $APP_PLUGIN_PATH dirs
DSOLoader::loadAllByEnvironment( ".ffs" );                       // $LD_LIBRARY_PATH dirs

Notes

  • The partial-failure throw lets a host load "as many plugins as possible" and then report the gaps: catch the exception, log e.missingFilename(), carry on.
  • Set a prefix to avoid pulling unrelated .sos out of a shared directory like /usr/lib.
  • Non-recursive by design — point it at a directory that contains only plugins.