MCPcopy Create free account
hub / github.com/VCVRack/Rack / init

Function init

src/plugin.cpp:265–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263////////////////////
264
265void 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
317static void destroyPlugin(Plugin* plugin) {

Callers

nothing calls this directly

Calls 14

loadPluginFunction · 0.85
userFunction · 0.85
isDirectoryFunction · 0.85
renameFunction · 0.85
createDirectoryFunction · 0.85
extractPackagesFunction · 0.85
loadPluginsFunction · 0.85
getPluginFunction · 0.85
isFileFunction · 0.85
unarchiveToDirectoryFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected