Symbian Zip解压问题
来源:互联网 发布:下载数据恢复 编辑:程序博客网 时间:2024/05/16 11:30
Symbian提供了解压ZIP的API,调用可以解压文件。如果知道zip文件中有什么文件,调用api进行解压还马马虎虎。
在实际应用中,如果需要解压某个zip文件,往往不知道这个压缩包中有些什么东西,但要求全部解压出来,这就不太好办了。
其实也可以把zip压缩包中的文件的文件名都列举出来,然后就可以依次读取每个文件了。
TInt CZipMgr::UnZipAd(){ TInt nRet = 0; CDesCArray* filesList; TInt nIdx = 0; filesList = new (ELeave) CDesCArrayFlat(30); if(iZipFile) { delete iZipFile; iZipFile = NULL; } TBuf<260> strZipPath; strZipPath.Append(_L("attach.zip")); if(!CFileUtils::FileExists(strZipPath)) goto END; iZipFile = CZipFile::NewL(iFs, strZipPath); nRet = GetZipedFiles(*filesList); if(0 >= nRet) goto END; for(nIdx = 0; nIdx < filesList->Count(); ++nIdx) { TFileName strFName; strFName.Copy((*filesList)[nIdx]); UnZipFile(strFName); }END: filesList->Reset(); delete filesList; return nRet;}TInt CZipMgr::GetZipedFiles(CDesCArray& aFiles){ TInt nRet = 0; aFiles.Reset(); if(!iZipFile) goto END; CZipFileMemberIterator* members = iZipFile->GetMembersL(); if(!members) goto END; CZipFileMember* pMem = members->NextL(); while(pMem) { aFiles.AppendL(*pMem->Name()); delete pMem; pMem = NULL; pMem = members->NextL(); } nRet = aFiles.Count();END: if(members) delete members; return nRet;}void CZipMgr::UnZipFile(const TDesC& aFile){ if(aFile[aFile.Length() - 1] == '\\') { return; } if(!iZipFile) return; TFileName strDescPath; strDescPath.Copy(strRootPath); strDescPath.Append(aFile); RZipFileMemberReaderStream* stream = NULL; CZipFileMember* member =iZipFile->CaseInsensitiveMemberL(aFile); if(!member) goto END; if(KErrNone != iZipFile->GetInputStreamL(member, stream) ) { goto END; } HBufC8* buffer =HBufC8::NewL(member->UncompressedSize()); TPtr8 bufferPtr(buffer->Des()); User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize())); CFileUtils::Save(strDescPath, buffer->Des());END: if(member) delete member; member = NULL; if(stream) delete stream; stream = NULL; if(buffer) delete buffer; buffer = NULL;}
- Symbian Zip解压问题
- Android Zip解压的问题
- linux zip解压乱码问题
- ubuntu解压zip文件乱码问题
- ubuntu解压zip文件中文乱码问题
- ubuntu解压zip文件乱码问题
- ubuntu解压zip文件乱码问题
- linux解压zip中文乱码问题
- ubuntu解压zip文件乱码问题
- ubuntu解压zip文件乱码问题
- zip压缩包解压乱码问题
- ubantu解压zip文件乱码问题
- ZIP解压
- ZIP解压
- ZIP解压
- zip解压
- 解压zip
- ZIp 解压
- 检索 COM 类工厂中 CLSID 为{...} 的组件时失败,出现以下错误: 80070005、8000401A的错误解决方法
- Android手机端使用Zipalign优化apk应用程序
- SWIG——万能粘合剂
- Qt 之 QGridLayout
- 截取字符串,中文不能截取半个
- Symbian Zip解压问题
- COM组件 接口(Interface)的来历
- Eclipse的使用秘籍,MyEclipse一样管用
- php做的主页验证码
- 鸡窝里的鹰
- mave2入门
- static_cast、dynamic_cast reinterpret_cast和const_
- poj1125floyd
- JSP 下载文件