示例#1
0
int guiLuaApi::l_download_file(lua_State *L) {
	GUIEngine* engine = get_engine(L);
	assert(engine != 0);

	const char *url    = luaL_checkstring(L, 1);
	const char *target = luaL_checkstring(L, 2);

	//check path
	std::string absolute_destination = fs::RemoveRelativePathComponents(target);

	if (guiLuaApi::isMinetestPath(absolute_destination)) {
		if (engine->downloadFile(url,absolute_destination)) {
			lua_pushboolean(L,true);
			return 1;
		}
	}
	lua_pushboolean(L,false);
	return 1;
}