| 263 | //////////////////// |
| 264 | |
| 265 | void init() { |
| 266 | // Don't re-initialize |
| 267 | assert(plugins.empty()); |
| 268 | |
| 269 | // Load Core |
| 270 | loadPlugin(""); |
| 271 | |
| 272 | // Get user plugins directory |
| 273 | if (settings::devMode) { |
| 274 | pluginsPath = asset::user("plugins"); |
| 275 | } |
| 276 | else { |
| 277 | pluginsPath = asset::user("plugins-" + APP_OS + "-" + APP_CPU); |
| 278 | } |
| 279 | |
| 280 | // In Rack <2.4.0, plugins dir was "plugins" regardless of arch. |
| 281 | // Rename old dir if running x64. |
| 282 | #if defined ARCH_X64 |
| 283 | std::string oldPluginsPath = asset::user("plugins"); |
| 284 | if (system::isDirectory(oldPluginsPath)) { |
| 285 | system::rename(oldPluginsPath, pluginsPath); |
| 286 | } |
| 287 | #endif |
| 288 | |
| 289 | system::createDirectory(pluginsPath); |
| 290 | |
| 291 | // Don't load plugins if safe mode is enabled |
| 292 | if (settings::safeMode) |
| 293 | return; |
| 294 | |
| 295 | // Extract packages and load plugins |
| 296 | extractPackages(pluginsPath); |
| 297 | loadPlugins(pluginsPath); |
| 298 | |
| 299 | // If Fundamental wasn't loaded, copy the bundled Fundamental package and load it |
| 300 | if (!settings::devMode && !getPlugin("Fundamental")) { |
| 301 | std::string fundamentalPackage = getFundamentalPackagePath(); |
| 302 | std::string fundamentalDir = system::join(pluginsPath, "Fundamental"); |
| 303 | if (fundamentalPackage != "" && system::isFile(fundamentalPackage)) { |
| 304 | INFO("Extracting bundled Fundamental package"); |
| 305 | try { |
| 306 | system::unarchiveToDirectory(fundamentalPackage.c_str(), pluginsPath.c_str()); |
| 307 | loadPlugin(fundamentalDir); |
| 308 | } |
| 309 | catch (Exception& e) { |
| 310 | WARN("Could not extract Fundamental package: %s", e.what()); |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | |
| 317 | static void destroyPlugin(Plugin* plugin) { |
nothing calls this directly
no test coverage detected