void sc_GetUserExtensionDirectory(char *str, int size) { sc_GetUserAppSupportDirectory(str, size); sc_AppendToPath(str, size, "Extensions"); }
void initialize_library(const char *uGensPluginPath) { gCmdLib = new HashTable<SC_LibCmd, Malloc>(&gMalloc, 64, true); gUnitDefLib = new HashTable<UnitDef, Malloc>(&gMalloc, 512, true); gBufGenLib = new HashTable<BufGen, Malloc>(&gMalloc, 512, true); gPlugInCmds = new HashTable<PlugInCmd, Malloc>(&gMalloc, 64, true); initMiscCommands(); #ifdef STATIC_PLUGINS IO_Load(&gInterfaceTable); Osc_Load(&gInterfaceTable); Delay_Load(&gInterfaceTable); BinaryOp_Load(&gInterfaceTable); Filter_Load(&gInterfaceTable); Gendyn_Load(&gInterfaceTable); LF_Load(&gInterfaceTable); Noise_Load(&gInterfaceTable); MulAdd_Load(&gInterfaceTable); Grain_Load(&gInterfaceTable); Pan_Load(&gInterfaceTable); Reverb_Load(&gInterfaceTable); Trigger_Load(&gInterfaceTable); UnaryOp_Load(&gInterfaceTable); DiskIO_Load(&gInterfaceTable); PhysicalModeling_Load(&gInterfaceTable); Test_Load(&gInterfaceTable); Demand_Load(&gInterfaceTable); DynNoise_Load(&gInterfaceTable); #if defined(SC_IPHONE) && !TARGET_IPHONE_SIMULATOR iPhone_Load(&gInterfaceTable); #endif FFT_UGens_Load(&gInterfaceTable); return; #endif // If uGensPluginPath is supplied, it is exclusive. bool loadUGensExtDirs = true; if(uGensPluginPath){ loadUGensExtDirs = false; SC_StringParser sp(uGensPluginPath, SC_STRPARSE_PATHDELIMITER); while (!sp.AtEnd()) { PlugIn_LoadDir(const_cast<char *>(sp.NextToken()), true); } } if(loadUGensExtDirs) { #ifdef SC_PLUGIN_DIR // load globally installed plugins if (sc_DirectoryExists(SC_PLUGIN_DIR)) { PlugIn_LoadDir(SC_PLUGIN_DIR, true); } #endif // load default plugin directory char pluginDir[MAXPATHLEN]; sc_GetResourceDirectory(pluginDir, MAXPATHLEN); sc_AppendToPath(pluginDir, SC_PLUGIN_DIR_NAME); if (sc_DirectoryExists(pluginDir)) { PlugIn_LoadDir(pluginDir, true); } } // get extension directories char extensionDir[MAXPATHLEN]; if (!sc_IsStandAlone() && loadUGensExtDirs) { // load system extension plugins sc_GetSystemExtensionDirectory(extensionDir, MAXPATHLEN); PlugIn_LoadDir(extensionDir, false); // load user extension plugins sc_GetUserExtensionDirectory(extensionDir, MAXPATHLEN); PlugIn_LoadDir(extensionDir, false); // load user plugin directories SC_StringParser sp(getenv("SC_PLUGIN_PATH"), SC_STRPARSE_PATHDELIMITER); while (!sp.AtEnd()) { PlugIn_LoadDir(const_cast<char *>(sp.NextToken()), true); } } #ifdef __APPLE__ /* on darwin plugins are lazily loaded (dlopen uses mmap internally), which can produce audible glitches when UGens have to be paged-in. to work around this we preload all the plugins by iterating through their memory space. */ unsigned long images = _dyld_image_count(); for(unsigned long i = 0; i < images; i++) { const mach_header *hdr = _dyld_get_image_header(i); unsigned long slide = _dyld_get_image_vmaddr_slide(i); const char *name = _dyld_get_image_name(i); uint32_t size; char *sect; if(!strcmp(name + (strlen(name) - 4), ".scx")) { read_section(hdr, slide, "__TEXT", "__text"); read_section(hdr, slide, "__TEXT", "__const"); read_section(hdr, slide, "__TEXT", "__cstring"); read_section(hdr, slide, "__TEXT", "__picsymbol_stub"); read_section(hdr, slide, "__TEXT", "__symbol_stub"); read_section(hdr, slide, "__TEXT", "__const"); read_section(hdr, slide, "__TEXT", "__literal4"); read_section(hdr, slide, "__TEXT", "__literal8"); read_section(hdr, slide, "__DATA", "__data"); read_section(hdr, slide, "__DATA", "__la_symbol_ptr"); read_section(hdr, slide, "__DATA", "__nl_symbol_ptr"); read_section(hdr, slide, "__DATA", "__dyld"); read_section(hdr, slide, "__DATA", "__const"); read_section(hdr, slide, "__DATA", "__mod_init_func"); read_section(hdr, slide, "__DATA", "__bss"); read_section(hdr, slide, "__DATA", "__common"); read_section(hdr, slide, "__IMPORT", "__jump_table"); read_section(hdr, slide, "__IMPORT", "__pointers"); } } #endif }
static void sc_InitCompileDirectory(void) { // main class library folder: only used for relative path resolution sc_GetResourceDirectory(gCompileDir, MAXPATHLEN-32); sc_AppendToPath(gCompileDir, MAXPATHLEN, "SCClassLibrary"); }
bool sc_ReadDir(SC_DirHandle* dir, const char* dirname, char* path, bool& skipEntry) { #ifdef _WIN32 bool success = true; if (dir->mAtEnd) return false; const char* entry = dir->mEntry.cFileName; if (sc_IsSpecialDirectory(entry) || (skipEntry && sc_SkipDirectory(entry))) { skipEntry = true; success = true; } else { skipEntry = false; success = true; } char entrypathname[PATH_MAX]; strncpy(entrypathname, dirname, PATH_MAX); sc_AppendToPath(entrypathname, PATH_MAX, dir->mEntry.cFileName); bool isAlias = false; sc_ResolveIfAlias(entrypathname, path, isAlias, PATH_MAX); if (!::FindNextFile(dir->mHandle, &dir->mEntry)) { dir->mAtEnd = true; } return true; #else if (!dir->mHandle) return false; dir->mEntry = readdir(dir->mHandle); if (!dir->mEntry) return false; const char* entry = dir->mEntry->d_name; if (sc_IsSpecialDirectory(entry) || (skipEntry && sc_SkipDirectory(entry))) { skipEntry = true; return true; } else { skipEntry = false; } // construct path from dir entry char entrypathname[PATH_MAX]; strncpy(entrypathname, dirname, PATH_MAX); sc_AppendToPath(entrypathname, PATH_MAX, dir->mEntry->d_name); // resolve path bool isAlias = false; if (sc_ResolveIfAlias(entrypathname, path, isAlias, strlen(entrypathname))<0) { skipEntry = true; } return true; #endif }