コード例 #1
0
ファイル: mods.cpp プロジェクト: 1CoreyDev1/minetest
void parseModContents(ModSpec &spec)
{
	// NOTE: this function works in mutual recursion with getModsInPath

	spec.depends.clear();
	spec.optdepends.clear();
	spec.is_modpack = false;
	spec.modpack_content.clear();

	// Handle modpacks (defined by containing modpack.txt)
	std::ifstream modpack_is((spec.path+DIR_DELIM+"modpack.txt").c_str());
	if(modpack_is.good()){ //a modpack, recursively get the mods in it
		modpack_is.close(); // We don't actually need the file
		spec.is_modpack = true;
		spec.modpack_content = getModsInPath(spec.path, true);

		// modpacks have no dependencies; they are defined and
		// tracked separately for each mod in the modpack
	}
	else{ // not a modpack, parse the dependencies
		std::ifstream is((spec.path+DIR_DELIM+"depends.txt").c_str());
		while(is.good()){
			std::string dep;
			std::set<char> symbols;
			if(parseDependsLine(is, dep, symbols)){
				if(symbols.count('?') != 0){
					spec.optdepends.insert(dep);
				}
				else{
					spec.depends.insert(dep);
				}
			}
		}
	}
}
コード例 #2
0
ファイル: content.cpp プロジェクト: Caellian/minetest
ContentType getContentType(const ContentSpec &spec)
{
	std::ifstream modpack_is((spec.path + DIR_DELIM + "modpack.txt").c_str());
	if (modpack_is.good()) {
		modpack_is.close();
		return ECT_MODPACK;
	}

	std::ifstream modpack2_is((spec.path + DIR_DELIM + "modpack.conf").c_str());
	if (modpack2_is.good()) {
		modpack2_is.close();
		return ECT_MODPACK;
	}

	std::ifstream init_is((spec.path + DIR_DELIM + "init.lua").c_str());
	if (init_is.good()) {
		init_is.close();
		return ECT_MOD;
	}

	std::ifstream game_is((spec.path + DIR_DELIM + "game.conf").c_str());
	if (game_is.good()) {
		game_is.close();
		return ECT_GAME;
	}

	std::ifstream txp_is((spec.path + DIR_DELIM + "texture_pack.conf").c_str());
	if (txp_is.good()) {
		txp_is.close();
		return ECT_TXP;
	}

	return ECT_UNKNOWN;
}