static int UTILS_API _e_file( const char * szBaseDir, const char * szFullPath, const char * szRelativePath, const void * pvSearchContext ) { IBlk * blk; char buf[128]; IFileStream *fs; IF8Stream *s; int roffset; fs = IFileStream_from_file(szFullPath, "rb"); if(!fs){ return 1; } s = __ucast__(IFileStream, IF8Stream, (fs)); blk = IBlk_from_stream(s); if(!blk){ __delete__(fs); return 1; } roffset = __vcall__(s, tell, (s)); load_res_stream(s); probe_blk_resources(blk); fprintf(fdb, "%d=%s,%c%c,%s", count, IBlk_class_name(blk), blk->h.magic >> 8, blk->h.magic & 0xff, szRelativePath ); f8_uuid_to_string(&blk->h.uuid, buf, sizeof(buf)); fprintf(fdb, ",%s", buf); fprintf(fdb, ",%d", roffset); fprintf(fdb, "\n"); delete_blk(blk); __delete__(fs); count++; return 1; }
/* ICBlk::load(IF8Stream * s) this will construct an in-memory composite block object. the most exciting part of F8 controller program. */ static __bool ICBlk_load(IBlk * blk, IF8Stream * s) { ICBlk * cblk; struct blk_hdr_t * h, _h; int i; IBlk * sb; union blk_pindef_t pd, ps, pt; f8_uuid uuid; cblk = __dcast__(IBlk, ICBlk, blk); h = &_h; if(__vcall__(s, get, (s, h, sizeof(struct blk_hdr_t))) != sizeof(struct blk_hdr_t) ) { return __false; } blk->h = *h; blk->h.u1.n_subblocks = 0; blk->h.u2.n_links = 0; blk->h.n_pins = 0; if(!__vcall__(s, get, (s, &blk->uuid, sizeof(blk->uuid)))) { goto __failed; } /* load sub-blocks */ for(i=0; i<h->u1.n_subblocks; i++) { sb = IBlk_from_stream(s); if(!sb) { goto __failed; } if(!ICBlk_add_blk(cblk, sb)) { delete_blk(sb); return __false; } } /* load links */ for(i=0; i<h->u2.n_links; i++) { if(!__vcall__(s, get, (s, &uuid, sizeof(uuid)))) { goto __failed; } if(!__vcall__(s, get, (s, &ps, sizeof(union blk_pindef_t)))) { goto __failed; } if(!__vcall__(s, get, (s, &pt, sizeof(union blk_pindef_t)))) { goto __failed; } locate_pin(blk, ps); locate_pin(blk, pt); if(!ps.pin || !pt.pin) { goto __failed; } if(!ICBlk_link(&uuid, ps.pin, pt.pin)) { goto __failed; } } /* load exports */ for(i=0; i<h->n_pins; i++) { if(!__vcall__(s, get, (s, &uuid, sizeof(uuid)))) { goto __failed; } if(!__vcall__(s, get, (s, &pd, sizeof(union blk_pindef_t)))) { goto __failed; } locate_pin(blk, pd); if(!pd.pin) { return __false; } if(!ICBlk_add_pin(&uuid, pd.pin)) { return __false; } } return __true; __failed: return __false; }
static __inline IBlk * _extract_blk(IMemStream * _s) { IF8Stream * s; s = __ucast__(IMemStream, IF8Stream, _s); return IBlk_from_stream(s); }