GraphDef* GraphDef_LoadDir(World *inWorld, char *dirname, GraphDef *inList) { SC_DirHandle *dir = sc_OpenDir(dirname); if (!dir) { scprintf("*** ERROR: open directory failed '%s'\n", dirname); return inList; } for (;;) { char diritem[MAXPATHLEN]; bool skipItem = false; bool validItem = sc_ReadDir(dir, dirname, diritem, skipItem); if (!validItem) break; if (skipItem) continue; if (sc_DirectoryExists(diritem)) { inList = GraphDef_LoadDir(inWorld, diritem, inList); } else { int dnamelen = strlen(diritem); if (strncmp(diritem+dnamelen-9, ".scsyndef", 9) == 0) { inList = GraphDef_Load(inWorld, diritem, inList); } } } sc_CloseDir(dir); return inList; }
GraphDef* GraphDef_LoadGlob(World *inWorld, const char *pattern, GraphDef *inList) { SC_GlobHandle* glob = sc_Glob(pattern); if (!glob) return inList; const char* filename; while ((filename = sc_GlobNext(glob)) != 0) { int len = strlen(filename); if (strncmp(filename+len-9, ".scsyndef", 9)==0) { inList = GraphDef_Load(inWorld, filename, inList); } // why? <sk> GraphDef_Load(inWorld, filename, inList); } sc_GlobFree(glob); return inList; }
GraphDef* GraphDef_LoadGlob(World *inWorld, const char *pattern, GraphDef *inList) { SC_Filesystem::Glob* glob = SC_Filesystem::makeGlob(pattern); if (!glob) return inList; bfs::path path; while (!(path = SC_Filesystem::globNext(glob)).empty()) { if (path.extension() == ".scsyndef") { inList = GraphDef_Load(inWorld, path, inList); } // why? <sk> GraphDef_Load(inWorld, path, inList); } SC_Filesystem::freeGlob(glob); return inList; }
GraphDef* GraphDef_LoadDir(World *inWorld, const bfs::path& dirname, GraphDef *inList) { boost::system::error_code ec; bfs::recursive_directory_iterator rditer(dirname, bfs::symlink_option::recurse, ec); if (ec) { scprintf( "*** ERROR: open directory failed '%s'\n", SC_Codecvt::path_to_utf8_str(dirname).c_str() ); return inList; } while (rditer != bfs::end(rditer)) { const bfs::path path = *rditer; if (bfs::is_directory(path)) { if (SC_Filesystem::instance().shouldNotCompileDirectory(path)) rditer.no_push(); else ; // do nothing; recursion will happen automatically } else if (path.extension() == ".scsyndef") { // ordinary file inList = GraphDef_Load(inWorld, path, inList); } else { // ignore file, wasn't a synth def } rditer.increment(ec); if (ec) { scprintf( "*** ERROR: Could not iterate on '%s': %s\n", SC_Codecvt::path_to_utf8_str(path).c_str(), ec.message().c_str() ); return inList; } } return inList; }