예제 #1
0
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;
}
예제 #2
0
/*
	import a resource from disk, and if the resource has
	already been loaded, increment its reference count.

	2005/6/24
	the load_from_disk branch is obsolete.
*/
F8RES_API __bool load_resource(
	const f8_uuid * id
	)
{
	RESMAP::iterator it;
	it = g_Resources.find(*id);
	if(it != g_Resources.end()){
		it->second.refcount++;
		return __true;
	}
	return __false;
#if 0
	IFileStream *fs;
	IF8Stream * str;
	char buf[43];
	
	f8_uuid_to_string(id, buf, sizeof(buf));
	strcat(buf, ".res");
	fs = IFileStream_from_file(buf, "rb");
	if(!fs){
		return __false;
	}
	str = __ucast__(IFileStream, IF8Stream, fs);
	h = _load_res_stream(str);
	if(h){
		if(*id != h->id){
			/* error in library */
			unload_resource(&h->id);
			h = 0;
		}		
	}

	__delete__(fs);
	return h? __true : __false;
#endif
}