Using gzip functionality
Login to reply to this topic.
Thu, 2005-07-14 15:29
Joined: 2004-06-29
Forum posts: 109
Hi all,

like some fellows before me I do want to inflate a gzip'ed file on the
phone. How can I do this? There are few resources on the net - however I
have created the following piece of code that compiles and executes
fine. It simply does not create any output...

8<---------------------------------------------
   RFs fs;

   User :: LeaveIfError (fs.Connect());
   CleanupClosePushL(fs);

   RFile output;
   output.Open(fs,
_L("c:\\test.zipx"),EFileRead|EFileWrite|EFileShareAny|EFileStreamText);

   CEZGZipToFile*gzipConverter ;
   gzipConverter = CEZGZipToFile::NewL(fs, _L("c:\\test.zip"), output);
   gzipConverter->InflateL();

   delete gzipConverter;
   gzipConverter = NULL;

   output.Close();   

   CleanupStack::PopAndDestroy(&fs);

8<---------------------------------------------

Since the CEZGZipToFile class is not documented, I have no idea whether
my usage is right or wrong.

Does anybody do gzip deflating with success? Maybe with some other
technique?

Any help would be very kind!
Thank you, Marcel

Thu, 2005-07-21 16:24
Joined: 2005-01-22
Forum posts: 60
Hi
Your usage is correct

But there is another thing  gzipConverter->InflateL(); will decopress only first block of your file you must decompress all file and use
  while( gzipConverter->InflateL()){}; or something.

I've tried to modify your code to this:

  RFile output;
  output.Open(fs,
  aDestination,EFileRead|EFileWrite|EFileShareAny|EFileStreamText);

   CEZGZipToFile*gzipConverter ;
   gzipConverter = CEZGZipToFile::NewL(fs,aSource, output);
   while( gzipConverter->InflateL()){};
  delete gzipConverter;
   gzipConverter = NULL;
   output.Close();   

and it's working !!!

Defalting works the same as Inflating just switch output and input




algis

Mon, 2005-07-25 08:32
Joined: 2004-06-29
Forum posts: 109
Hi algis,

Yeah, you are right. There must be that while thing! With that, it works here too! Why they do not document such things???!!

br, Marcel
Tue, 2007-09-25 11:48
Joined: 2007-09-24
Forum posts: 2


I have this function in one of my project , got from a web site. But not working. Please Help!!

void DeCompressAFile(TDesC& aSrcName, TDesC& aDstName)
{
TBuf8<256> msg8;TBuf<256> msg16;

RFs fs;User::LeaveIfError(fs.Connect());
fs.SetSessionPath(_L("C:\\")); // change to your req. Path
RFile file;
TInt err = file.Open(fs,aDstName,EFileRead);

if(err != KErrNone)
{
msg8.Format(_L8("Error Reading File"));
msg16.Copy(msg8);
ERRDLG(msg16);
return;
}
msg8.Format(_L8("Before"));
msg16.Copy(msg8);
ERRDLG(msg16);

CEZGZipToFile *zip = CEZGZipToFile::NewLC(fs, aSrcName, file); //The function stops here witout crash and returns.

msg8.Format(_L8("CEZGZipToFile::before loop"));
msg16.Copy(msg8);
ERRDLG(msg16);

TInt tempi = 0;
while(zip->InflateL()) // while loop req. donot remove
{
tempi++;
}

msg8.Format(_L8("Completed"));
msg16.Copy(msg8);
ERRDLG(msg16);

CleanupStack::PopAndDestroy(); // zip
file.Close();
fs.Close();
}


copyright 2003-2009 NewLC SARL