ZLIB help!

This is a discussion on ZLIB help! within the C Programming forums, part of the General Programming Boards category; Hi, I am trying to use zlib and implement it using the zpipe.c example and I am always getting a ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    2

    ZLIB help!

    Hi, I am trying to use zlib and implement it using the zpipe.c example and I am always getting a Z_DATA_ERROR, I thought it might be how I am setting up the file pointers.
    if((source = fopen("/Users/macd2/Desktop/testzipfile.story", "r+")) == NULL)
    printf("Cannot open %s\n", fileName);
    if ((dest = fopen("/Users/macd2/Desktop/unzipped.txt", "w+")) == NULL)
    printf("Cannot open %s\n", "xmlfile");

    then I call my modified inf() with
    ret = inf(source, dest);

    but I always get that error, any ideas?
    thanks,
    Anthony

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    No clue.. I doubt the problem is anywhere in the code you posted (except that you seem to continue after an error, which is wrong)

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I would try opening both files in binary mode:
    Code:
    if((source = fopen("/Users/macd2/Desktop/testzipfile.story", "rb")) == NULL)
    .
    .
    if ((dest = fopen("/Users/macd2/Desktop/unzipped.txt", "w+b")) == NULL)

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    2
    thanks for the help swoopy, i did change it to rb and w+b but i am still having a problem, has anyone actually done unzipping from inside a c program and if so what did you use. I am trying to uncompress *.story files which are just compressed archives, I am writing an import function so I need to get to the story.xml file thats in that archive.
    thanks,
    Anthony

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Window Size in Zlib
    By indrajit_muk in forum C Programming
    Replies: 3
    Last Post: 11-26-2008, 09:49 AM
  2. Zlib dll for windows
    By vin_pll in forum C++ Programming
    Replies: 8
    Last Post: 02-02-2008, 03:33 AM
  3. Implementing Zlib function
    By vin_pll in forum C++ Programming
    Replies: 6
    Last Post: 01-24-2008, 10:37 PM
  4. Heap corruption using zlib inflate
    By The Wazaa in forum C++ Programming
    Replies: 0
    Last Post: 03-29-2007, 12:43 PM
  5. zlib
    By walden in forum C++ Programming
    Replies: 0
    Last Post: 11-18-2003, 05:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21