status_t ModuleManager::GetModule(const char *path, module_info **_info) { if (path == NULL || _info == NULL) return B_BAD_VALUE; BAutolock _lock(fModules); status_t error = B_OK; Module *module = fModules.FindModule(path); if (module == NULL) { // module not yet loaded, try to get it // get the responsible add-on ModuleAddOn *addon = NULL; error = _GetAddOn(path, &addon); if (error == B_OK) { // add-on found, get the module if (module_info *info = addon->FindModuleInfo(path)) { module = new Module(addon, info); fModules.AddModule(module); } else { _PutAddOn(addon); error = B_ENTRY_NOT_FOUND; } } } // "get" the module if (error == B_OK) error = module->Get(); if (error == B_OK) *_info = module->Info(); return error; }
// PutModule status_t ModuleManager::PutModule(const char *path) { if (path == NULL) return B_BAD_VALUE; BAutolock _lock(fModules); if (Module *module = fModules.FindModule(path)) { if (module->Put()) { ModuleAddOn *addon = module->AddOn(); fModules.RemoveModule(module); delete module; _PutAddOn(addon); } } else return B_BAD_VALUE; return B_OK; }