Solved

Z_DATA_ERROR ,Windows Programming

Posted on 2010-11-22
2
862 Views
Last Modified: 2012-05-10
Hi Experts

                      I am using Zlib for compressing of my data. It is giving the Z_DATA_ERROR every time.I am not able to figure out the reason for this. Please let me know where I am doing wrong the source code is given below:

bBuffcompress= new BYTE[12*1024*1024];
bBuffUncompress      = new BYTE[12*1024*1024];
DWORD dwUncompressSize =12*1024*1024;
do
{
        DWORD  dwByteRead = 0;
       memset(&drCluChunk,0x00,sizeof(drCluChunk));
       ReadFile(hBackupFile, &drCluChunk, sizeof(drCluChunk),&dwByteRead,NULL);
       dwtotelbyteRead = dwtotelbyteRead + dwByteRead;
       if(drCluChunk.dwTotalCluster != 0)
      {
      DWORD mFTclusteinfile = OnResetClusterLocation(m_BackupParameter._dwRootStartCluster);
      DWORD dwCurrentFilePosition;  
      dwCurrentFilePosition = SetFilePointer(hBackupFile,0,NULL,FILE_CURRENT);
      if(drCluChunk.dwClusterStartFrom == 0)
      {
            //Partition boot record
            DWORD dw =0;
            LARGE_INTEGER      lrMovePos ={0},
            lrCurrentPos ={0};
            lrMovePos.QuadPart = 7;
            SetFilePointerEx(hBackupFile,lrMovePos ,&lrCurrentPos, FILE_CURRENT);
            memset(&ntfsHeader,0x00,sizeof(ntfsHeader));
            BYTE *Buffer = new BYTE[SECTSIZE];
            ReadFile(hBackupFile,Buffer,SECTSIZE,&dw,NULL);      
            memcpy(&ntfsHeader,Buffer,sizeof(ntfsHeader));
            LARGE_INTEGER      lrMovePos1 ={0},
            lrCurrentPos1 ={0};
            lrMovePos1.QuadPart = dwCurrentFilePosition;
            SetFilePointerEx(hBackupFile,lrMovePos1,&lrCurrentPos1,FILE_BEGIN);

      }
             if(mFTclusteinfile !=0)
      {
            DWORD dwReturnValue = 0;
            DWORD comprssbuffsize = 0;
            LARGE_INTEGER      lrMovePos ={0},
            lrCurrentPos ={0};
            lrMovePos.QuadPart = mFTclusteinfile;
            SetFilePointerEx(hBackupFile,lrMovePos ,&lrCurrentPos, FILE_CURRENT);
            bBuffcompress      = new BYTE[drCluChunk.dwCompressSize];
         ReadFile(hBackupFile,bBuffcompress,drCluChunk.dwCompressSize,&dwReturnValue,NULL);
int nFlag = uncompress(bBuffUncompress,&dwUncompressSize,bBuffcompress,drCluChunk.dwCompressSize);
}


nFlag gives (-3) the Z_DATA_ERROR.


PLease help me out  I am stuck here.
0
Comment
Question by:davinder101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
masheik earned 500 total points
ID: 34187739
Hi,

  That error occurs if the data input is corrupted...

  Reference can be found here.

  http://www.zlib.net/zlib_how.html

  Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format,
  which means that either the data is not a zlib stream to begin with, or that the data was corrupted
  somewhere along the way since it was compressed. The other error to be processed is  
  Z_MEM_ERROR, which can occur since memory allocation is deferred until inflate() needs it, unlike
  deflate(),whose memory is allocated at the start by deflateInit().
0
 
LVL 9

Expert Comment

by:masheik
ID: 34187740
Hi,

  That error occurs if the data input is corrupted...

  Reference can be found here.

  http://www.zlib.net/zlib_how.html

  Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format,
  which means that either the data is not a zlib stream to begin with, or that the data was corrupted
  somewhere along the way since it was compressed. The other error to be processed is  
  Z_MEM_ERROR, which can occur since memory allocation is deferred until inflate() needs it, unlike
  deflate(),whose memory is allocated at the start by deflateInit().
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question