WEB开发网
开发学院手机开发Symbian 开发 symbian s60 实现 zip 文件解压到指定目录 阅读

symbian s60 实现 zip 文件解压到指定目录

 2010-03-13 20:28:00 来源:WEB开发网   
核心提示:NewLc上有个zip例子能够遍历和从一个包里面解压一个文件出来,我稍微整理了一下实现一个带有目录的zip文件解压到指定目录,symbian s60 实现 zip 文件解压到指定目录,view plaincopy to clipboardprint?//Add by windcaoLOCAL_C void Extrac

NewLc上有个zip例子能够遍历和从一个包里面解压一个文件出来。

我稍微整理了一下实现一个带有目录的zip文件解压到指定目录。

view plaincopy to clipboardprint?

//Add by windcao

LOCAL_C void ExtractionAllL(RFs& aFileSession, CZipFile& aZipFile,

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);

1 2 3  下一页

Tags:symbian 实现 zip

编辑录入:coldstar [复制链接] [打 印]
赞助商链接