void CContentBuilder::buildContent() { for (int i = 0; i < mRefsCount; i++) { IContent* content = buildContent(mRefs[i]); if (CContentProvider::instance()->setPrimaryContent(content, mRefs[i]) == E_FAILED) delete content; } }
Instance &Block::matchInstance( Session &session, Instance &instance ) { // find exist instance for (Instance &exist: instances) { if (instance.in(exist)) { return exist; } } // not found instances.push_back(instance); session.insert(instance); // render (before body) instance.content.insert( [&](OutputContext &oc) { instance.renderFuncHead(oc); } ); // build buildContent(session, instance); if (!getOption(BlockOption::manual_lock)) { instance.lock(); } // render (after body) instance.content.insert( [&](OutputContext &oc) { instance.renderFuncTail(oc); } ); // render header instance.header.insert( [&](OutputContext &och) { instance.renderStruct(och); } ); // return return instance; }
bool VIsoFile::build(char *inDir) { DirList *dirList, *tail; struct dirent2 **dirs; int count; int idx = 0; rootList = new DirList; rootList->path = dupString(inDir); rootList->content = NULL; rootList->contentJoliet = NULL; rootList->fileList = NULL; rootList->idx = idx++; rootList->next = NULL; dirList = tail = rootList; while (dirList) { count = scandir(dirList->path, &dirs, select_directories, alphasort); if (count < 0) return false; for (int i = 0; i < count; i++) { tail = tail->next = new DirList; tail->path = createPath(dirList->path, dirs[i]->d_name); tail->content = NULL; tail->contentJoliet = NULL; tail->idx = idx++; tail->fileList = NULL; tail->next = NULL; free(dirs[i]); } free(dirs); dirList = dirList->next; } dirList = rootList; while (dirList) { struct dirent2 **files; FileList *fileList = NULL; bool error = false; count = scandir(dirList->path, &files, select_files, alphasort); for (int i = 0; i < count; i++) { if (!error) { bool multipart = false; char *p = strrchr(files[i]->d_name, '.'); if (p && strlen(p+1) == 5) { if (p[1] == '6' && p[2] == '6' && p[3] == '6' && isdigit(p[4]) && isdigit(p[5])) { multipart = true; if (p[4] != '0' || p[5] != '0') { free(files[i]); continue; } } } if (i == 0) { fileList = dirList->fileList = new FileList; } else { fileList = fileList->next = new FileList; } fileList->path = createPath(dirList->path, files[i]->d_name); fileList->multipart = multipart; fileList->next = NULL; if (getFileSizeAndProcessMultipart(fileList->path, &fileList->size)) { fileList->rlba = filesSizeSectors; filesSizeSectors += bytesToSectors(fileList->size); } else { error = true; } } free(files[i]); } if (count >= 0) free(files); if (error) return false; dirList = dirList->next; } // Add iso directories dirList = rootList; while (dirList) { if (!buildContent(dirList, false)) { return false; } dirList = dirList->next; } // Add joliet directories dirList = rootList; while (dirList) { if (!buildContent(dirList, true)) { return false; } dirList = dirList->next; } pathTableL = buildPathTable(false, false, &pathTableSize); pathTableM = buildPathTable(true, false, &pathTableSize); pathTableJolietL = buildPathTable(false, true, &pathTableSizeJoliet); pathTableJolietM = buildPathTable(true, true, &pathTableSizeJoliet); uint32_t isoLba = (0xA000/0x800) + (bytesToSectors(pathTableSize) * 2) + (bytesToSectors(pathTableSizeJoliet) * 2); uint32_t jolietLba = isoLba + dirsSizeSectors; uint32_t filesLba = jolietLba + dirsSizeSectorsJoliet; fixLba(isoLba, jolietLba, filesLba); return true; }