void MCF::parseMCF() { if (m_bStopped) return; UTIL::FS::FileHandle hFile; getReadHandle(hFile); safe_delete(m_pFileList); MCFCore::MCFHeader tempHeader; tempHeader.readFromFile(hFile); setHeader(&tempHeader); hFile.seek(tempHeader.getXmlStart()); uint32 xmlBuffLen = tempHeader.getXmlSize()+1; UTIL::MISC::Buffer xmlBuff(xmlBuffLen, true); hFile.read(xmlBuff, tempHeader.getXmlSize()); if (getHeader()->getFlags() & MCFCore::MCFHeaderI::FLAG_NOTCOMPRESSED) { parseXml(xmlBuff, xmlBuffLen); } else { UTIL::MISC::BZ2Worker worker(UTIL::MISC::BZ2_DECOMPRESS); worker.write(xmlBuff, xmlBuffLen, true); worker.doWork(); if (worker.getLastStatus() != BZ_STREAM_END) throw gcException(ERR_BZ2, worker.getLastStatus(), "Failed to decompress mcf header xml"); size_t bz2BuffLen = worker.getReadSize(); UTIL::MISC::Buffer bz2Buff(bz2BuffLen); worker.read(bz2Buff, bz2BuffLen); parseXml(bz2Buff, bz2BuffLen); } }
cocos2d::CCDictionary *dictionaryFromPlist(const char *pFileName){ xmlDoc *doc(0); xmlNode *root_element(0); /* * this initialize the library and check potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION /*parse the file and get the DOM */ // on android i seem to have to go through ccfileutils to get the data, may as well always do it unsigned long uSize(0); xmlChar * xmlBuff(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pFileName, "r", &uSize)); if (uSize) doc = xmlReadMemory((const char *)xmlBuff, uSize, "", 0, XML_PARSE_NOBLANKS); CC_SAFE_DELETE_ARRAY(xmlBuff); //could not parse the file pFileName! assert(doc); /*Get the root element node */ root_element = xmlDocGetRootElement(doc); // print_element_names(root_element, ""); cocos2d::CCDictionary *d = (cocos2d::CCDictionary *) allocValueForNode(root_element->children); d->autorelease(); /*free the document */ xmlFreeDoc(doc); /* *Free the global variables that may *have been allocated by the parser. */ xmlCleanupParser(); return d; }