×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Getting trailer and header info from GZIP files using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]
__NOEDITSECTION__
+
{{Archived|timestamp=20120313130335|user=roy.debjit| }}
{{KBCS}}
+
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''ID''' || CS000948
+
|'''Creation date''' || May 14, 2008
+
|-
+
|'''Platform''' || S60 3rd Edition, FP1
+
|'''Tested on devices''' || Nokia N93
+
|-
+
|'''Category''' || Symbian C++
+
|'''Subcategory''' || Files/Data
+
|}
+
 
+
 
+
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''Keywords (APIs, classes, methods, functions):''' RFile, EZGZipFile, TEZGZipHeader, TEZGZipTrailer, RFile::Open(),EZGZipFile::IsGzipFileL(), EZGZipFile::LocateAndReadTrailerL(), EZGZipFile::ReadHeaderL(),EZGZipFile::EFText,EZGZipFile::EFHcrc, EZGZipFile::EFExtra,EZGZipFile::EFName,EZGZipFile::EFComment
+
|}
+
  
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= Nokia N93
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= S60 3rd Edition, FP1
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= RFile, EZGZipFile, TEZGZipHeader, TEZGZipTrailer, RFile::Open(),EZGZipFile::IsGzipFileL(), EZGZipFile::LocateAndReadTrailerL(), EZGZipFile::ReadHeaderL(),EZGZipFile::EFText,EZGZipFile::EFHcrc, EZGZipFile::EFExtra,EZGZipFile::EFName,EZGZipFile::EFComment
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080506
 +
|author= [[User:Aknyman]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Files/Data
 +
|id= CS000948
 +
}}
 +
 
 
==Overview==
 
==Overview==
  
This snippet shows how to get the trailer and the header info from GZIP files.
+
{{Abstract|This snippet shows how to get the trailer and the header info from GZIP files.}}
  
 
The trailer part of GZIP file should contain the following data:
 
The trailer part of GZIP file should contain the following data:
Line 149: Line 157:
 
==See also==
 
==See also==
  
[[CS000949 - Compressing and decompressing GZIP files]]
+
[[Archived:Compressing and decompressing GZIP files using Symbian C++]]
  
 
The GZIP format is specified in http://www.faqs.org/rfcs/rfc1952.html.
 
The GZIP format is specified in http://www.faqs.org/rfcs/rfc1952.html.
 
 
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]][[Category:S60 3rd Edition, Feature Pack 1]]
 

Latest revision as of 01:56, 16 September 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Article
Keywords: RFile, EZGZipFile, TEZGZipHeader, TEZGZipTrailer, RFile::Open(),EZGZipFile::IsGzipFileL(), EZGZipFile::LocateAndReadTrailerL(), EZGZipFile::ReadHeaderL(),EZGZipFile::EFText,EZGZipFile::EFHcrc, EZGZipFile::EFExtra,EZGZipFile::EFName,EZGZipFile::EFComment
Created: aknyman (06 May 2008)
Last edited: lpvalente (16 Sep 2012)

Contents

[edit] Overview

This snippet shows how to get the trailer and the header info from GZIP files.

The trailer part of GZIP file should contain the following data:

  • CRC32
  • Input size (calculated from the original uncompressed data)

The actual GZIP header is defined to contain the following fields:

  • Fixed value for ID1 = 31
  • Fixed value for ID2 = 139
  • Compression method (8 is the standard)
  • Flags (0 = no flags are set)
  • Modification time (time stamp in Unix format)
  • Extra flags (maximum compression - fastest algorithm)
  • Operating System

This snippet can be self-signed.

[edit] MMP file

The following libraries are required:

LIBRARY efsrv.lib
LIBRARY ezlib.lib

[edit] Header file

[edit] Source file

#include <ezgzip.h>
#include <f32file.h>
 
 
void GetGZipFileTrailerAndHeaderInfoL(RFs& aRfs, const TDesC& aFileName)
{
RFile file;
TEZGZipHeader header;
TEZGZipTrailer trailer;
 
if (!EZGZipFile::IsGzipFileL(aRfs,aFileName))
{
_LIT(KIsNotGZipFile,"File:%S is not in GZip format\n");
console->Printf(KIsNotGZipFile,&aFileName);
console->Getch();
User::Leave(KErrGeneral);
}
 
EZGZipFile::LocateAndReadTrailerL(aRfs, aFileName, trailer);
_LIT(KTrailer,"CRC32 = %d size = %d\n");
console->Printf(KTrailer,trailer.iCrc32,trailer.iSize);
 
User::LeaveIfError(file.Open(aRfs,aFileName,EFileStream | EFileRead | EFileShareAny));
EZGZipFile::ReadHeaderL(file, header);
 
_LIT(KFileId1,"ID1 = %d\n");
console->Printf(KFileId1,header.iId1);
_LIT(KFileId2,"ID2 = %d\n");
console->Printf(KFileId2,header.iId2);
_LIT(KCompressionMethod,"compression method = %d\n");
console->Printf(KCompressionMethod,header.iCompressionMethod);
_LIT(KFlags,"flags = %d\n");
console->Printf(KFlags,header.iFlags);
_LIT(KTimeStamp,"time stamp = %d\n");
console->Printf(KTimeStamp,header.iTime);
_LIT(KExtraFlags,"extra flags %d\n");
console->Printf(KExtraFlags,header.iExtraFlags);
_LIT(KOS,"OS %d\n");
console->Printf(KOS,header.iOs);
 
if (header.iFlags & EZGZipFile::EFText)
{
_LIT(KText,"text flag set\n");
console->Printf(KText);
}
 
if (header.iFlags & EZGZipFile::EFHcrc)
{
_LIT(KCrc16,"CRC16 = %d\n");
console->Printf(KCrc16,header.iCrc);
}
 
if (header.iFlags & EZGZipFile::EFExtra)
{
_LIT(KExtraLength,"extra length %d\n");
console->Printf(KExtraLength,header.iXlen);
HBufC *buf = HBufC::NewLC(header.iExtra->Length());
buf->Des().Copy(*header.iExtra);
console->Printf(*buf);
CleanupStack::PopAndDestroy(); //buf
}
 
if (header.iFlags & EZGZipFile::EFName)
{
_LIT(KFName,"fname: %S\n");
HBufC *buf = HBufC::NewLC(header.iFname->Length());
buf->Des().Copy(*header.iFname);
console->Printf(KFName,buf);
CleanupStack::PopAndDestroy(); //buf
}
 
if (header.iFlags & EZGZipFile::EFComment)
{
_LIT(KComment,"comment: %S\n");
HBufC *buf = HBufC::NewLC(header.iComment->Length());
buf->Des().Copy(*header.iComment);
console->Printf(KComment,buf);
CleanupStack::PopAndDestroy(); //buf
}
}

[edit] Postconditions

The trailer and header info from the given GZIP file is printed to the console.

[edit] See also

Archived:Compressing and decompressing GZIP files using Symbian C++

The GZIP format is specified in http://www.faqs.org/rfcs/rfc1952.html.

This page was last modified on 16 September 2012, at 01:56.
123 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×