本文整理汇总了C++中Compressor::createReadStream方法的典型用法代码示例。如果您正苦于以下问题:C++ Compressor::createReadStream方法的具体用法?C++ Compressor::createReadStream怎么用?C++ Compressor::createReadStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compressor
的用法示例。
在下文中一共展示了Compressor::createReadStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyFileToNewZip
bool ZipArchive::copyFileToNewZip(CentralDir *cdir, Stream *newZipStream)
{
// [tom, 1/24/2007] Using the stored compressor allows us to copy the raw
// data regardless of compression method without having to re-compress it.
Compressor *comp = Compressor::findCompressor(Stored);
if(comp == NULL)
return false;
if(! mStream->setPosition(cdir->mLocalHeadOffset))
return false;
// Copy file header
// FIXME [tom, 1/24/2007] This will currently not copy the extra fields
FileHeader fh;
if(! fh.read(mStream))
return false;
cdir->mLocalHeadOffset = newZipStream->getPosition();
if(! fh.write(newZipStream))
return false;
// Copy file data
Stream *readS = comp->createReadStream(cdir, mStream);
if(readS == NULL)
return false;
bool ret = newZipStream->copyFrom(readS);
// [tom, 1/24/2007] closeFile() just frees the relevant filters and
// thus it is safe to call from here.
closeFile(readS);
return ret;
}
示例2: method
Stream *ZipArchive::openFileForRead(const CentralDir *fileCD)
{
if(mMode != Read && mMode != ReadWrite)
return NULL;
if((fileCD->mInternalFlags & (CDFileDeleted | CDFileOpen)) != 0)
return NULL;
Stream *stream = mStream;
if(fileCD->mInternalFlags & CDFileDirty)
{
// File is dirty, we need to read from the temporary file
for(S32 i = 0;i < mTempFiles.size();++i)
{
if(mTempFiles[i]->getCentralDir() == fileCD)
{
// Found the temporary file
if(! mTempFiles[i]->rewind())
{
if(isVerbose())
Con::errorf("ZipArchive::openFile - %s: %s is dirty, but could not rewind temporary file?", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
return NULL;
}
stream = mTempFiles[i];
break;
}
}
if(stream == mStream)
{
if(isVerbose())
Con::errorf("ZipArchive::openFile - %s: %s is dirty, but no temporary file found?", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
return NULL;
}
}
else
{
// Read from the zip file directly
if(! mStream->setPosition(fileCD->mLocalHeadOffset))
{
if(isVerbose())
Con::errorf("ZipArchive::openFile - %s: Could not locate local header for file %s", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
return NULL;
}
FileHeader fh;
if(! fh.read(mStream))
{
if(isVerbose())
Con::errorf("ZipArchive::openFile - %s: Could not read local header for file %s", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
return NULL;
}
}
Stream *attachTo = stream;
U16 compMethod = fileCD->mCompressMethod;
if(fileCD->mFlags & Encrypted)
{
if(fileCD->mCompressMethod == AESEncrypted)
{
// [tom, 1/19/2007] Whilst AES support does exist, I'm not including it in TGB
// to avoid having to deal with crypto export legal issues.
Con::errorf("ZipArchive::openFile - %s: File %s is AES encrypted, but AES is not supported in this version.", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
}
else
{
ZipCryptRStream *cryptStream = new ZipCryptRStream;
cryptStream->setPassword(DEFAULT_ZIP_PASSWORD);
cryptStream->setFileEndPos(stream->getPosition() + fileCD->mCompressedSize);
if(! cryptStream->attachStream(stream))
{
delete cryptStream;
return NULL;
}
attachTo = cryptStream;
}
}
Compressor *comp = Compressor::findCompressor(compMethod);
if(comp == NULL)
{
if(isVerbose())
Con::errorf("ZipArchive::openFile - %s: Unsupported compression method (%d) for file %s", mFilename ? mFilename : "<no filename>", fileCD->mCompressMethod, fileCD->mFilename.c_str());
return NULL;
}
return comp->createReadStream(fileCD, attachTo);
}