Created
July 5, 2018 21:37
-
-
Save oatmealraisin/be72e7035b6436a2abc016ebdc3d907a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/select.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
#include <zlib.h> | |
#define CHUNK 16384 | |
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) | |
# include <fcntl.h> | |
# include <io.h> | |
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) | |
#else | |
# define SET_BINARY_MODE(file) | |
#endif | |
unsigned char decompressGzip(const char *gzFileName, const char *destFileName) { | |
gzFile gzf = gzopen(gzFileName, "rb"); | |
FILE *destFile = fopen(destFileName, "wb"); | |
SET_BINARY_MODE(gzf); | |
char buffer[CHUNK]; | |
int num_read = 0; | |
int total_read = 0; | |
while((num_read = gzread(gzf, buffer, sizeof(buffer))) > 0) { | |
printf("Num read %d\n", num_read); | |
total_read += num_read; | |
if(num_read != fwrite(buffer, 1, num_read, destFile)) printf("Something"); | |
} | |
printf("Total read: %d\n", total_read); | |
printf("EOF %d\n", gzeof(gzf)); | |
gzclose(gzf); | |
fclose(destFile); | |
//remove(gzFileName); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment