Пример #1
0
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;
}
Пример #2
0
static bool passOne_ProcessDir(const char *dirname, int level)
{
	if (!sc_DirectoryExists(dirname))
		return true;

	if (compiledDirectories.find(std::string(dirname)) != compiledDirectories.end())
		// already compiled
		return true;

	bool success = true;

	if (gLanguageConfig && gLanguageConfig->pathIsExcluded(dirname)) {
		post("\texcluding dir: '%s'\n", dirname);
		return success;
	}

	if (level == 0) post("\tcompiling dir: '%s'\n", dirname);

	SC_DirHandle *dir = sc_OpenDir(dirname);
	if (!dir) {
		error("open directory failed '%s'\n", dirname); fflush(stdout);
		return false;
	}

	for (;;) {
		char diritem[MAXPATHLEN];
		bool skipItem = true;
		bool validItem = sc_ReadDir(dir, dirname, diritem, skipItem);
		if (!validItem) break;
		if (skipItem) continue;

		if (sc_DirectoryExists(diritem)) {
			success = passOne_ProcessDir(diritem, level + 1);
		} else {
			success = passOne_ProcessOneFile(diritem, level + 1);
		}

		if (!success) break;
	}

	compiledDirectories.insert(std::string(dirname));
	sc_CloseDir(dir);
	return success;
}
bool PlugIn_LoadDir(const char *dirname, bool reportError)
{
#ifndef NDEBUG
	scprintf("PlugIn_LoadDir(%s)\n", dirname);
#endif
	bool success = true;

	SC_DirHandle *dir = sc_OpenDir(dirname);
	if (!dir) {
		if (reportError) {
			scprintf("*** ERROR: open directory failed '%s'\n", dirname); fflush(stdout);
		}
		return false;
	}

	int firstCharOffset = strlen(dirname)+1;

	for (;;) {
		char diritem[MAXPATHLEN];
		bool skipItem = true;
		bool validItem = sc_ReadDir(dir, dirname, diritem, skipItem);
		if (!validItem) break;
		if (skipItem || (*(diritem+firstCharOffset) == '.')) continue;  // skip files+folders whose first char is a dot

        if (sc_DirectoryExists(diritem)) {
			success = PlugIn_LoadDir(diritem, reportError);
        } else {
			int dnamelen = strlen(diritem);
			int extlen = strlen(SC_PLUGIN_EXT);
			char *extptr = diritem+dnamelen-extlen;
			if (strncmp(extptr, SC_PLUGIN_EXT, extlen) == 0) {
				success = PlugIn_Load(diritem);
			}
        }

		if (!success) continue;
	}

	sc_CloseDir(dir);
	return success;
}