Ejemplo n.º 1
0
int FSZip::load(string backfile, string filename, FileBuffer *p, bool async)
{
	Zip zip;

	if (zip.Open(backfile.substr(1)))
		return -1;

	if (!zip.check_file_exist(filename))
		return -1;

	if (async)
	{
		p->m_aync_thread = thread(zip_async_load, backfile, filename, p);
	}
	else
	{
		shared_ptr<FileBuffer> pzip = zip.get_file_buff(filename);
		if (pzip == NULL)
			return -1;

		p->swap(*pzip);
		p->m_loaded = true;
	}
	return 0;
}
Ejemplo n.º 2
0
int zip_async_load(string zipfile, string fn, FileBuffer * buff)
{
	std::lock_guard<mutex> lock(buff->m_async_mutex);

	Zip zip;
	if (zip.Open(zipfile.substr(1)))
		return -1;

	shared_ptr<FileBuffer> p = zip.get_file_buff(fn);
	if (p == NULL)
		return -1;

	buff->swap(*p);
	buff->m_loaded = true;
	return 0;
}