当前位置: 首页>>代码示例>>C++>>正文


C++ FileHandle::read方法代码示例

本文整理汇总了C++中util::fs::FileHandle::read方法的典型用法代码示例。如果您正苦于以下问题:C++ FileHandle::read方法的具体用法?C++ FileHandle::read怎么用?C++ FileHandle::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util::fs::FileHandle的用法示例。


在下文中一共展示了FileHandle::read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: decompressDiff

void HGTController::decompressDiff(uint64 size, UTIL::FS::FileHandle &fhSrc, UTIL::FS::FileHandle &fhDest)
{
	uint64 done = 0;

	uint32 buffSize = 10*1024;
	char buff[10*1024] = {0};

	UTIL::MISC::BZ2Worker worker(UTIL::MISC::BZ2_DECOMPRESS);

	fhSrc.read(done, [&worker, &fhDest](const unsigned char* buff, uint32 size) -> bool
	{
		UTIL::FS::FileHandle* pFile = &fhDest;

		worker.write((const char*)buff, size, [pFile](const unsigned char* tbuff, uint32 tsize) -> bool
		{
			pFile->write((const char*)tbuff, tsize);
			return false;
		});

		return false;
	});

	worker.end([&fhDest](const unsigned char* tbuff, uint32 tsize) -> bool
	{
		fhDest.write((const char*)tbuff, tsize);
		return false;
	});
}
开发者ID:boskee,项目名称:Desurium-1,代码行数:28,代码来源:HGTController.cpp

示例2: parseMCF

void MCF::parseMCF()
{
	gcTrace("");

	if (m_bStopped)
		return;

	UTIL::FS::FileHandle hFile;
	getReadHandle(hFile);

	m_pFileList.clear();

	MCFCore::MCFHeader tempHeader;
	tempHeader.readFromFile(hFile);
	setHeader(&tempHeader);

	hFile.seek(tempHeader.getXmlStart());

	uint32 xmlBuffLen = tempHeader.getXmlSize()+1;
	UTIL::MISC::Buffer xmlBuff(xmlBuffLen, true);

	hFile.read(xmlBuff, tempHeader.getXmlSize());


	if (getHeader()->getFlags() & MCFCore::MCFHeaderI::FLAG_NOTCOMPRESSED)
	{
		parseXml(xmlBuff, xmlBuffLen);
	}
	else
	{
		UTIL::MISC::BZ2Worker worker(UTIL::MISC::BZ2_DECOMPRESS);

		worker.write(xmlBuff, xmlBuffLen, true);
		worker.doWork();

		if (worker.getLastStatus() != BZ_STREAM_END)
			throw gcException(ERR_BZ2, worker.getLastStatus(), "Failed to decompress mcf header xml");

		size_t bz2BuffLen = worker.getReadSize();

		if (bz2BuffLen == 0)
			throw gcException(ERR_BZ2, worker.getLastStatus(), "Failed to decompress mcf header xml (zero size)");

		UTIL::MISC::Buffer bz2Buff(bz2BuffLen);

		worker.read(bz2Buff, bz2BuffLen);
		parseXml(bz2Buff, bz2BuffLen);
	}
}
开发者ID:aromis,项目名称:desura-app,代码行数:49,代码来源:MCF_Save.cpp

示例3: postProcessing

void SMTController::postProcessing()
{
	if (m_uiNumber == 1)
		return;

	UTIL::FS::FileHandle fhSource;
	UTIL::FS::FileHandle fhSink;

	UTIL::FS::Path path(m_szFile, "", true);

	uint64 sinkSize = UTIL::FS::getFileSize(path);

	try
	{
		fhSink.open(path, UTIL::FS::FILE_APPEND);
	}
	catch (gcException &)
	{
		return;
	}

	char buff[BLOCKSIZE];

	for (size_t x=1; x<m_vWorkerList.size(); x++)
	{
		SMTWorkerInfo *worker = m_vWorkerList[x];

		uint64 fileSize = UTIL::FS::getFileSize(UTIL::FS::PathWithFile(worker->file));
		uint64 done = 0;

		uint32 readSize = BLOCKSIZE;

		try
		{
			fhSource.open(worker->file.c_str(), UTIL::FS::FILE_READ);
			while (fileSize > done)
			{
				if ((fileSize-done) < (uint64)readSize)
					readSize = (uint32)(fileSize-done);

				fhSource.read(buff, readSize);
				fhSink.write(buff, readSize);

				done += readSize;
			}
			fhSource.close();
		}
		catch (gcException &)
		{
		}

		for (size_t y=0; y<worker->vFileList.size(); y++)
		{
			uint32 index = worker->vFileList[y];
			MCFCore::MCFFile *temp = m_rvFileList[index];

			if (!temp)
				continue;

			temp->setOffSet( temp->getOffSet() + sinkSize );
		}

		sinkSize += fileSize;
		UTIL::FS::delFile(UTIL::FS::PathWithFile(worker->file));
	}

	if (m_bCreateDiff == false)
		return;
}
开发者ID:Alasaad,项目名称:Desurium,代码行数:69,代码来源:SMTController.cpp


注:本文中的util::fs::FileHandle::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。