00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00021 #include "OpenCLibzheader.h"
00022
00023
00024
00025
00026 void Error(const char * msg)
00027 {
00028 printf( " %s\n", msg);
00029 getchar();
00030 getchar();
00031 exit(1);
00032 }
00033
00034
00035
00036
00037
00038 void GzUnCompress(gzFile in, FILE * out)
00039
00040 {
00041 static char buf[BUFLEN];
00042 int len;
00043 int err;
00044
00045 for (;;)
00046 {
00047 len = gzread(in, buf, sizeof(buf));
00048 if (len < 0) Error (gzerror(in, &err));
00049 if (len == 0) break;
00050
00051 if ((int)fwrite(buf, 1, (unsigned)len, out) != len)
00052 {
00053 Error("failed fwrite");
00054 }
00055 }
00056 if (fclose(out)) Error("failed fclose");
00057
00058 if (gzclose(in) != Z_OK)
00059
00060 Error("failed gzclose");
00061
00062
00063
00064 }
00065
00066
00067
00068
00069
00070
00071 void FileUnCompress( char * file )
00072
00073 {
00074 static char buf[MAX_NAME_LEN];
00075 char *infile, *outfile;
00076 FILE *out;
00077 gzFile in;
00078 char choice[3];
00079 uInt len = (uInt)strlen(file);
00080 strcpy(buf, file);
00081
00082 if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0)
00083 {
00084 infile = file;
00085 outfile = buf;
00086 outfile[len-3] = '\0';
00087 }
00088 else
00089 {
00090 outfile = file;
00091 infile = buf;
00092 strcat(infile, GZ_SUFFIX);
00093 }
00094 in = gzopen(infile, "rb");
00095
00096 if (in == NULL)
00097 {
00098
00099 Error("file not found ...try again \n");
00100
00101 }
00102 out = fopen(outfile, "wb");
00103 if (out == NULL)
00104 {
00105 gzclose(in);
00106 }
00107
00108 GzUnCompress(in, out);
00109
00110 printf("do you want to delete the original file (y /n) \n");
00111
00112 scanf("%s",choice);
00113
00114 if(choice[0] == 'y')
00115 unlink(file);
00116 printf(" Congrats .... uncompression done ...u can find uncompressed file in the same directory as of the source file\n");
00117
00118 }
00119
00120