lemur::parse::KeyfileDocMgr::~KeyfileDocMgr() { writeTOC(); delete[](myDoc); poslookup.close(); doclookup.close(); }
void lemur::dictionary::PDict::close() { // flush any open list(s) flush(); // flush new stats entry writeTOC(); dict.close(); targetIDs.close(); dictEntries.close(); name = ""; }
void lemur::parse::KeyfileDocMgr::buildMgr() { _readOnly = false; myparser->setTextHandler(this); cerr << "Building " << IDname << endl; for (int i = numOldSources; i < sources.size(); i++) { fileid = i; cerr << " *Parsing " << sources[i] << endl; myparser->parse(sources[i]); } writeTOC(); }
void ResourcePack::save(String path) { FILE* fp = fopen(path.c_str(), "wb"); if (!fp) throw Exception("Unable to open destination file"); // Write file header writeHeader(fp); // Store TOC start position size_t tocStart = ftell(fp); writeTOC(fp); // Write all files for (auto& iter: entries) { writeFile(fp, iter.second); } // Rewrite TOC, now that we have more data about each file fseek(fp, long(tocStart), SEEK_SET); writeTOC(fp); // Done fclose(fp); }
char * embed(lua_State * L, int nlibs, char ** libs) { // create name of output file - if we're invoked as // enceladus.exe main.lua lib1.lua lib2.lua // the name of the output file is main.lua-enceladus.exe char * myname = options.outname; if (!myname) { myname = strrchr(options.targetname, '/'); if (!myname) myname = strrchr(options.targetname, '\\'); if (!myname) myname = options.targetname; else myname++; } char * outname = options.outname; if (!outname) { size_t namelen = strlen(libs[0]) + strlen(myname) + 2; outname = malloc(namelen); snprintf(outname, namelen, "%s-%s", libs[0], myname); } // copy input file to output file size_t size; uint8_t * buf = loadfile(options.targetname, &size); FILE * fout = fopen(outname, "wb"); if (!fout) { perror(outname); return NULL; } fwrite(buf, size, 1, fout); fclose(fout); free(buf); if (!writeTOC(L, outname, nlibs, libs)) return NULL; return outname; }
Serializer::~Serializer() { if (mWrite) writeTOC(); }
//------------------------------------------------------------ static void writeBooks(BookCaseDB& db, info_lib *mmdb, const char *bcname, DBCursor *node_meta_cursor, int compressed, char *comp_agent, hashTable<CC_String,BTCollectable> &hd) { DBTable *bookMeta = db.table(BookCaseDB::BookMeta, DB::READ); DBCursor BookCursor(*bookMeta); DBTable *toc = db.table(BookCaseDB::TOCTree, DB::READ); DBCursor TocCursor(*toc); DBTable *dlp = db.table(BookCaseDB::TOCPath, DB::READ); DBCursor DlpCursor(*dlp); DBTable *sgml = db.table(BookCaseDB::NodeSGML, DB::READ); DBCursor SgmlCursor(*sgml); DBCursor *GraphicsCursorPtr; int process_graphics = 1; try { DBTable *graphics = db.table(BookCaseDB::Graphics, DB::READ); GraphicsCursorPtr = new DBCursor( *graphics ); } catch (PosixError&, p){ /* error opening graphics stuff... skip graphics */ process_graphics = 0; }end_try const char *bookLocator; int tabQty; char **tabLines; while(BookCursor.next(STRING_CODE, &bookLocator, SKIP_CODE, SKIP_CODE, SKIP_CODE, /* @# skipping shortlists not suported yet... */ SHORT_LIST_CODE, &tabQty, STRING_CODE, &tabLines, SKIP_CODE, /* skip access data */ NULL)){ hashTable<CC_String,BTCollectable> node_tab(hash_func); node_table( node_meta_cursor, bookLocator, node_tab); writeDLP(db, mmdb, bcname, bookLocator, DlpCursor, node_tab); writeTOC(db, mmdb, bcname, bookLocator, TocCursor); writeSGML(db, bookLocator, SgmlCursor, hd); if ( process_graphics ) { writeGraphics(db, bookLocator, *GraphicsCursorPtr, compressed, comp_agent ); } node_tab.clearAndDestroy(); } if ( process_graphics ) { delete GraphicsCursorPtr; } }