symbian s60 实现 zip 文件解压到指定目录
2010-03-13 20:28:00 来源:WEB开发网NewLc上有个zip例子能够遍历和从一个包里面解压一个文件出来。
我稍微整理了一下实现一个带有目录的zip文件解压到指定目录。
view plaincopy to clipboardprint?
//Add by windcao
LOCAL_C void ExtractionAllL(RFs& aFileSession, C
const TDesC& aPath)
{
CZipFileMemberIterator* members = aZipFile.GetMembersL();
CleanupStack::PushL(members);
CZipFileMember* member;
while ((member = members->NextL()) != 0)
{
RZipFileMemberReaderStream* stream;
aZipFile.GetInputStreamL(member, stream);
CleanupStack::PushL(member);
CleanupStack::PushL(stream);
// Extracts aFileName to a buffer.
// If the file is quite huge, then read the file in streaming mode.
// For example, use 4KB buffer and read it in an active object.
HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());
TPtr8 bufferPtr(buffer->Des());
User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));
// Store the buffer to a file.
// It saves the file to KExtractedPath directory, the file name is the same
// as the one in the .zip file.
TFileName fileName;
fileName.Append(aPath);
fileName.Append(*(member->Name()));
console->Printf(*(member->Name()));
BaflUtils::EnsurePathExistsL(aFileSession, fileName);
更多精彩
赞助商链接