本文整理汇总了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;
});
}
示例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);
}
}
示例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;
}