diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-07-10 16:25:50 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-07-10 16:25:50 +0000 |
commit | 942bebf4b29cbae800614df17d9d4af650a8d3ba (patch) | |
tree | 30a7562f433d51999aa251446d1b1ece1deec959 | |
parent | e4b71bb7d41a7daab67322a567c6ddafafe383fa (diff) |
Fixed uncompressing
-rw-r--r-- | src/htsback.c | 16 | ||||
-rw-r--r-- | src/htszlib.c | 12 |
2 files changed, 9 insertions, 19 deletions
diff --git a/src/htsback.c b/src/htsback.c index d5460fe..745a80c 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -457,22 +457,8 @@ int back_nsoc_overall(struct_back * sback) { } /* generate temporary file on lien_back */ +/* Note: utf-8 */ static int create_back_tmpfile(httrackp * opt, lien_back *const back) { -/* TEMPORARY */ -/* TEMPORARY */ - char *const tmp = tempnam(StringBuff(opt->path_html_utf8), "httrack_temporaryGzipFile_"); - - if (tmp != NULL) { - strcpybuff(back->tmpfile_buffer, tmp); - free(tmp); - back->tmpfile = back->tmpfile_buffer; -return 0; - } else { - back->tmpfile = NULL; - } -/* TEMPORARY */ -/* TEMPORARY */ - // do not use tempnam() but a regular filename back->tmpfile_buffer[0] = '\0'; if (back->url_sav != NULL && back->url_sav[0] != '\0') { diff --git a/src/htszlib.c b/src/htszlib.c index f78d778..47cb53c 100644 --- a/src/htszlib.c +++ b/src/htszlib.c @@ -56,10 +56,11 @@ int hts_zunpack(char *filename, char *newfile) { int ret = -1; char catbuff[CATBUFF_SIZE]; - if (filename && newfile) { + if (filename != NULL && newfile != NULL) { if (filename[0] && newfile[0]) { - // not: NOT an UTF-8 filename - gzFile gz = gzopen(filename, "rb"); + FILE *const in = FOPEN(fconv(catbuff, filename), "rb"); + const int fd_in = in != NULL ? fileno(in) : -1; + gzFile gz = gzdopen(fd_in, "rb"); if (gz) { FILE *const fpout = FOPEN(fconv(catbuff, newfile), "wb"); @@ -71,7 +72,7 @@ int hts_zunpack(char *filename, char *newfile) { do { char BIGSTK buff[1024]; - nr = gzread(gz, buff, 1024); + nr = gzread(gz, buff, sizeof(buff)); if (nr > 0) { size += nr; if (fwrite(buff, 1, nr, fpout) != nr) @@ -84,6 +85,9 @@ int hts_zunpack(char *filename, char *newfile) { gzclose(gz); ret = (int) size; } + if (in != NULL) { + fclose(in); + } } } return ret; |