Solved

Z_DATA_ERROR ,Windows Programming

Posted on 2010-11-22
2
863 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…
Suggested Courses

630 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