blob: 7e5f80da683fec66ff73ab40597bdf482d944f49 [file] [log] [blame]
Yann Collet4856a002015-01-24 01:58:16 +01001/*
2 fileio.c - File i/o handler
3 Copyright (C) Yann Collet 2013-2015
4
5 GPL v2 License
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 You can contact the author at :
22 - zstd source repository : https://github.com/Cyan4973/zstd
23 - Public forum : https://groups.google.com/forum/#!forum/lz4c
24*/
25/*
26 Note : this is stand-alone program.
27 It is not part of ZSTD compression library, it is a user program of ZSTD library.
28 The license of ZSTD library is BSD.
29 The license of this file is GPLv2.
30*/
31
Yann Colleteeb8ba12015-10-22 16:55:40 +010032/* *************************************
Yann Colletb1f3f4b2015-10-18 22:18:32 +010033* Tuning options
Yann Colleteeb8ba12015-10-22 16:55:40 +010034***************************************/
Yann Colletb1f3f4b2015-10-18 22:18:32 +010035#ifndef ZSTD_LEGACY_SUPPORT
36/**LEGACY_SUPPORT :
37* decompressor can decode older formats (starting from Zstd 0.1+) */
38# define ZSTD_LEGACY_SUPPORT 1
Yann Collet9f432922015-11-09 17:42:17 +010039#endif
Yann Colletb1f3f4b2015-10-18 22:18:32 +010040
41
Yann Colleteeb8ba12015-10-22 16:55:40 +010042/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +010043* Compiler Options
Yann Colleteeb8ba12015-10-22 16:55:40 +010044***************************************/
Yann Collet4856a002015-01-24 01:58:16 +010045/* Disable some Visual warning messages */
46#ifdef _MSC_VER
47# define _CRT_SECURE_NO_WARNINGS
48# define _CRT_SECURE_NO_DEPRECATE /* VS2005 */
49# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
50#endif
51
Yann Collet4856a002015-01-24 01:58:16 +010052#define _FILE_OFFSET_BITS 64 /* Large file support on 32-bits unix */
53#define _POSIX_SOURCE 1 /* enable fileno() within <stdio.h> on unix */
54
55
Yann Colleteeb8ba12015-10-22 16:55:40 +010056/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +010057* Includes
Yann Colleteeb8ba12015-10-22 16:55:40 +010058***************************************/
Yann Collet9f432922015-11-09 17:42:17 +010059#include <stdio.h> /* fprintf, fopen, fread, _fileno, stdin, stdout */
60#include <stdlib.h> /* malloc, free */
61#include <string.h> /* strcmp, strlen */
62#include <time.h> /* clock */
63#include <errno.h> /* errno */
64#include <sys/types.h> /* stat64 */
65#include <sys/stat.h> /* stat64 */
Yann Colletb1f3f4b2015-10-18 22:18:32 +010066#include "mem.h"
Yann Collet4856a002015-01-24 01:58:16 +010067#include "fileio.h"
Yann Collet88fcd292015-11-25 14:42:45 +010068#include "zstd_static.h" /* ZSTD_magicNumber */
69#include "zstd_buffered_static.h"
Yann Collet4856a002015-01-24 01:58:16 +010070
Yann Colletb1f3f4b2015-10-18 22:18:32 +010071#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1)
Yann Collet88fcd292015-11-25 14:42:45 +010072# include "zstd_legacy.h" /* legacy */
Yann Colletaa074052015-10-30 11:21:50 +010073# include "fileio_legacy.h" /* legacy */
Yann Colleteeb8ba12015-10-22 16:55:40 +010074#endif
Yann Colletb1f3f4b2015-10-18 22:18:32 +010075
Yann Collet4856a002015-01-24 01:58:16 +010076
Yann Colleteeb8ba12015-10-22 16:55:40 +010077/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +010078* OS-specific Includes
Yann Colleteeb8ba12015-10-22 16:55:40 +010079***************************************/
Yann Collet4856a002015-01-24 01:58:16 +010080#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
81# include <fcntl.h> /* _O_BINARY */
82# include <io.h> /* _setmode, _isatty */
83# ifdef __MINGW32__
Yann Collet88fcd292015-11-25 14:42:45 +010084 // int _fileno(FILE *stream); /* seems no longer useful /* MINGW somehow forgets to include this windows declaration into <stdio.h> */
Yann Collet4856a002015-01-24 01:58:16 +010085# endif
Yann Colletb5e06dc2015-07-04 23:20:56 -080086# define SET_BINARY_MODE(file) { int unused = _setmode(_fileno(file), _O_BINARY); (void)unused; }
Yann Collet4856a002015-01-24 01:58:16 +010087# define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream))
88#else
89# include <unistd.h> /* isatty */
90# define SET_BINARY_MODE(file)
91# define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
92#endif
93
Yann Colletb7d6e8f2015-11-09 18:20:39 +010094#if !defined(S_ISREG)
95# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
96#endif
97
Yann Collet4856a002015-01-24 01:58:16 +010098
Yann Colleteeb8ba12015-10-22 16:55:40 +010099/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +0100100* Constants
Yann Colleteeb8ba12015-10-22 16:55:40 +0100101***************************************/
Yann Collet4856a002015-01-24 01:58:16 +0100102#define KB *(1U<<10)
103#define MB *(1U<<20)
104#define GB *(1U<<30)
105
106#define _1BIT 0x01
107#define _2BITS 0x03
108#define _3BITS 0x07
109#define _4BITS 0x0F
110#define _6BITS 0x3F
111#define _8BITS 0xFF
112
113#define BIT6 0x40
114#define BIT7 0x80
115
Yann Collet88fcd292015-11-25 14:42:45 +0100116#define BLOCKSIZE (128 KB)
117#define ROLLBUFFERSIZE (BLOCKSIZE*8*64)
Yann Collet4856a002015-01-24 01:58:16 +0100118
119#define FIO_FRAMEHEADERSIZE 5 /* as a define, because needed to allocated table on stack */
120#define FSE_CHECKSUM_SEED 0
121
122#define CACHELINE 64
123
124
Yann Colleteeb8ba12015-10-22 16:55:40 +0100125/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +0100126* Macros
Yann Colleteeb8ba12015-10-22 16:55:40 +0100127***************************************/
Yann Collet4856a002015-01-24 01:58:16 +0100128#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
129#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
130static U32 g_displayLevel = 2; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
131
132#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
133 if ((FIO_GetMilliSpan(g_time) > refreshRate) || (g_displayLevel>=4)) \
134 { g_time = clock(); DISPLAY(__VA_ARGS__); \
135 if (g_displayLevel>=4) fflush(stdout); } }
136static const unsigned refreshRate = 150;
137static clock_t g_time = 0;
138
139
Yann Colleteeb8ba12015-10-22 16:55:40 +0100140/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +0100141* Local Parameters
Yann Colleteeb8ba12015-10-22 16:55:40 +0100142***************************************/
Yann Collet4856a002015-01-24 01:58:16 +0100143static U32 g_overwrite = 0;
144
145void FIO_overwriteMode(void) { g_overwrite=1; }
146void FIO_setNotificationLevel(unsigned level) { g_displayLevel=level; }
147
148
Yann Colleteeb8ba12015-10-22 16:55:40 +0100149/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +0100150* Exceptions
Yann Colleteeb8ba12015-10-22 16:55:40 +0100151***************************************/
152#ifndef DEBUG
153# define DEBUG 0
154#endif
Yann Collet4856a002015-01-24 01:58:16 +0100155#define DEBUGOUTPUT(...) if (DEBUG) DISPLAY(__VA_ARGS__);
156#define EXM_THROW(error, ...) \
157{ \
158 DEBUGOUTPUT("Error defined at %s, line %i : \n", __FILE__, __LINE__); \
159 DISPLAYLEVEL(1, "Error %i : ", error); \
160 DISPLAYLEVEL(1, __VA_ARGS__); \
161 DISPLAYLEVEL(1, "\n"); \
162 exit(error); \
163}
164
165
Yann Colleteeb8ba12015-10-22 16:55:40 +0100166/* *************************************
Yann Collet4856a002015-01-24 01:58:16 +0100167* Functions
Yann Colleteeb8ba12015-10-22 16:55:40 +0100168***************************************/
Yann Collet4856a002015-01-24 01:58:16 +0100169static unsigned FIO_GetMilliSpan(clock_t nPrevious)
170{
171 clock_t nCurrent = clock();
172 unsigned nSpan = (unsigned)(((nCurrent - nPrevious) * 1000) / CLOCKS_PER_SEC);
173 return nSpan;
174}
175
176
177static void FIO_getFileHandles(FILE** pfinput, FILE** pfoutput, const char* input_filename, const char* output_filename)
178{
179 if (!strcmp (input_filename, stdinmark))
180 {
181 DISPLAYLEVEL(4,"Using stdin for input\n");
182 *pfinput = stdin;
183 SET_BINARY_MODE(stdin);
184 }
185 else
186 {
187 *pfinput = fopen(input_filename, "rb");
188 }
189
190 if (!strcmp (output_filename, stdoutmark))
191 {
192 DISPLAYLEVEL(4,"Using stdout for output\n");
193 *pfoutput = stdout;
194 SET_BINARY_MODE(stdout);
195 }
196 else
197 {
198 /* Check if destination file already exists */
199 *pfoutput=0;
200 if (strcmp(output_filename,nulmark)) *pfoutput = fopen( output_filename, "rb" );
201 if (*pfoutput!=0)
202 {
203 fclose(*pfoutput);
204 if (!g_overwrite)
205 {
206 char ch;
207 if (g_displayLevel <= 1) /* No interaction possible */
208 EXM_THROW(11, "Operation aborted : %s already exists", output_filename);
209 DISPLAYLEVEL(2, "Warning : %s already exists\n", output_filename);
210 DISPLAYLEVEL(2, "Overwrite ? (Y/N) : ");
211 ch = (char)getchar();
212 if ((ch!='Y') && (ch!='y')) EXM_THROW(11, "Operation aborted : %s already exists", output_filename);
213 }
214 }
215 *pfoutput = fopen( output_filename, "wb" );
216 }
217
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100218 if ( *pfinput==0 ) EXM_THROW(12, "Pb opening src : %s", input_filename);
219 if ( *pfoutput==0) EXM_THROW(13, "Pb opening dst : %s", output_filename);
Yann Collet4856a002015-01-24 01:58:16 +0100220}
221
Yann Collet9f432922015-11-09 17:42:17 +0100222
223static U64 FIO_getFileSize(const char* infilename)
224{
225 int r;
226#if defined(_MSC_VER)
227 struct _stat64 statbuf;
228 r = _stat64(infilename, &statbuf);
229#else
230 struct stat statbuf;
231 r = stat(infilename, &statbuf);
232#endif
233 if (r || !S_ISREG(statbuf.st_mode)) return 0;
234 return (U64)statbuf.st_size;
235}
236
237
Yann Collet2acb5d32015-10-29 16:49:43 +0100238unsigned long long FIO_compressFilename(const char* output_filename, const char* input_filename, int cLevel)
Yann Collet4856a002015-01-24 01:58:16 +0100239{
240 U64 filesize = 0;
241 U64 compressedfilesize = 0;
242 BYTE* inBuff;
Yann Collet4856a002015-01-24 01:58:16 +0100243 BYTE* outBuff;
Yann Collet88fcd292015-11-25 14:42:45 +0100244 size_t inBuffSize = ZBUFF_recommendedCInSize();
245 size_t outBuffSize = ZBUFF_recommendedCOutSize();
Yann Collet4856a002015-01-24 01:58:16 +0100246 FILE* finput;
247 FILE* foutput;
Yann Collet88fcd292015-11-25 14:42:45 +0100248 size_t sizeCheck, errorCode;
249 ZBUFF_CCtx* ctx;
250
251 /* Allocate Memory */
252 ctx = ZBUFF_createCCtx();
253 inBuff = (BYTE*)malloc(inBuffSize);
254 outBuff = (BYTE*)malloc(outBuffSize);
255 if (!inBuff || !outBuff || !ctx) EXM_THROW(21, "Allocation error : not enough memory");
Yann Collet4856a002015-01-24 01:58:16 +0100256
Yann Collet5be2dd22015-11-11 13:43:58 +0100257 /* init */
Yann Collet4856a002015-01-24 01:58:16 +0100258 FIO_getFileHandles(&finput, &foutput, input_filename, output_filename);
Yann Collet9f432922015-11-09 17:42:17 +0100259 filesize = FIO_getFileSize(input_filename);
Yann Collet88fcd292015-11-25 14:42:45 +0100260 errorCode = ZBUFF_compressInit_advanced(ctx, ZSTD_getParams(cLevel, filesize));
261 if (ZBUFF_isError(errorCode)) EXM_THROW(22, "Error initializing compression");
Yann Collet9f432922015-11-09 17:42:17 +0100262 filesize = 0;
Yann Collet4856a002015-01-24 01:58:16 +0100263
264 /* Main compression loop */
265 while (1)
266 {
267 size_t inSize;
268
269 /* Fill input Buffer */
Yann Collet88fcd292015-11-25 14:42:45 +0100270 inSize = fread(inBuff, (size_t)1, inBuffSize, finput);
Yann Collet4856a002015-01-24 01:58:16 +0100271 if (inSize==0) break;
272 filesize += inSize;
Yann Colletd7233d62015-11-22 14:40:51 +0100273 DISPLAYUPDATE(2, "\rRead : %u MB ", (U32)(filesize>>20));
Yann Collet4856a002015-01-24 01:58:16 +0100274
Yann Collet88fcd292015-11-25 14:42:45 +0100275 {
276 /* Compress (buffered streaming ensures appropriate formatting) */
277 size_t usedInSize = inSize;
278 size_t cSize = outBuffSize;
279 size_t result = ZBUFF_compressContinue(ctx, outBuff, &cSize, inBuff, &usedInSize);
280 if (ZBUFF_isError(result))
281 EXM_THROW(23, "Compression error : %s ", ZBUFF_getErrorName(result));
282 if (inSize != usedInSize)
283 /* inBuff should be entirely consumed since buffer sizes are recommended ones */
284 EXM_THROW(24, "Compression error : input block not fully consumed");
Yann Collet4856a002015-01-24 01:58:16 +0100285
Yann Collet88fcd292015-11-25 14:42:45 +0100286 /* Write cBlock */
287 sizeCheck = fwrite(outBuff, 1, cSize, foutput);
288 if (sizeCheck!=cSize) EXM_THROW(25, "Write error : cannot write compressed block into %s", output_filename);
289 compressedfilesize += cSize;
290 }
Yann Collet4856a002015-01-24 01:58:16 +0100291
292 DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (U32)(filesize>>20), (double)compressedfilesize/filesize*100);
293 }
294
295 /* End of Frame */
Yann Collet88fcd292015-11-25 14:42:45 +0100296 {
297 size_t cSize = outBuffSize;
298 size_t result = ZBUFF_compressEnd(ctx, outBuff, &cSize);
299 if (result!=0) EXM_THROW(26, "Compression error : cannot create frame end");
Yann Collet4856a002015-01-24 01:58:16 +0100300
Yann Collet88fcd292015-11-25 14:42:45 +0100301 sizeCheck = fwrite(outBuff, 1, cSize, foutput);
302 if (sizeCheck!=cSize) EXM_THROW(27, "Write error : cannot write frame end into %s", output_filename);
303 compressedfilesize += cSize;
304 }
Yann Collet4856a002015-01-24 01:58:16 +0100305
306 /* Status */
307 DISPLAYLEVEL(2, "\r%79s\r", "");
308 DISPLAYLEVEL(2,"Compressed %llu bytes into %llu bytes ==> %.2f%%\n",
309 (unsigned long long) filesize, (unsigned long long) compressedfilesize, (double)compressedfilesize/filesize*100);
310
311 /* clean */
312 free(inBuff);
313 free(outBuff);
Yann Collet88fcd292015-11-25 14:42:45 +0100314 ZBUFF_freeCCtx(ctx);
Yann Collet5b147602015-08-25 17:41:46 +0100315 fclose(finput);
Yann Collet61d08c52015-08-25 18:13:32 +0100316 if (fclose(foutput)) EXM_THROW(28, "Write error : cannot properly close %s", output_filename);
Yann Collet4856a002015-01-24 01:58:16 +0100317
318 return compressedfilesize;
319}
320
321
Yann Colletbe50aaa2015-09-10 23:26:09 +0100322unsigned long long FIO_decompressFrame(FILE* foutput, FILE* finput,
Yann Collet88fcd292015-11-25 14:42:45 +0100323 BYTE* inBuff, size_t inBuffSize, size_t alreadyLoaded,
Yann Colletbe50aaa2015-09-10 23:26:09 +0100324 BYTE* outBuff, size_t outBuffSize,
Yann Collet88fcd292015-11-25 14:42:45 +0100325 ZBUFF_DCtx* dctx)
Yann Collet4856a002015-01-24 01:58:16 +0100326{
Yann Collet88fcd292015-11-25 14:42:45 +0100327 U64 frameSize = 0;
328 size_t readSize=alreadyLoaded;
Yann Collet4856a002015-01-24 01:58:16 +0100329
Yann Collet4856a002015-01-24 01:58:16 +0100330 /* Main decompression Loop */
Yann Collet88fcd292015-11-25 14:42:45 +0100331 ZBUFF_decompressInit(dctx);
332 while (1)
Yann Collet4856a002015-01-24 01:58:16 +0100333 {
Yann Collet88fcd292015-11-25 14:42:45 +0100334 /* Decode */
335 size_t sizeCheck;
336 size_t inSize=readSize, decodedSize=outBuffSize;
337 size_t inStart=0;
338 size_t toRead = ZBUFF_decompressContinue(dctx, outBuff, &decodedSize, inBuff+inStart, &inSize);
339 if (ZBUFF_isError(toRead)) EXM_THROW(36, "Decoding error : %s", ZBUFF_getErrorName(toRead));
Yann Collet88fcd292015-11-25 14:42:45 +0100340 readSize -= inSize;
341 inStart += inSize;
342
343 /* Write block */
344 sizeCheck = fwrite(outBuff, 1, decodedSize, foutput);
345 if (sizeCheck != decodedSize) EXM_THROW(37, "Write error : unable to write data block to destination file");
346 frameSize += decodedSize;
347 DISPLAYUPDATE(2, "\rDecoded : %u MB... ", (U32)(frameSize>>20) );
348
Yann Collet31d18062015-11-27 14:07:36 +0100349 if (toRead == 0) break;
Yann Collet88fcd292015-11-25 14:42:45 +0100350 if (readSize) continue; /* still some data left within inBuff */
Yann Collet4856a002015-01-24 01:58:16 +0100351
352 /* Fill input buffer */
Yann Collet88fcd292015-11-25 14:42:45 +0100353 if (toRead > inBuffSize) EXM_THROW(34, "too large block");
Yann Collet4856a002015-01-24 01:58:16 +0100354 readSize = fread(inBuff, 1, toRead, finput);
Yann Collet88fcd292015-11-25 14:42:45 +0100355 if (readSize != toRead) EXM_THROW(35, "Read error");
Yann Collet4856a002015-01-24 01:58:16 +0100356 }
357
Yann Collet88fcd292015-11-25 14:42:45 +0100358 return frameSize;
Yann Colletbe50aaa2015-09-10 23:26:09 +0100359}
360
361
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100362unsigned long long FIO_decompressFilename(const char* output_filename, const char* input_filename)
363{
364 FILE* finput, *foutput;
365 BYTE* inBuff=NULL;
Yann Collet88fcd292015-11-25 14:42:45 +0100366 size_t inBuffSize = ZBUFF_recommendedDInSize();
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100367 BYTE* outBuff=NULL;
Yann Collet88fcd292015-11-25 14:42:45 +0100368 size_t outBuffSize = ZBUFF_recommendedDOutSize();
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100369 U64 filesize = 0;
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100370 size_t toRead;
371 size_t sizeCheck;
372
373
374 /* Init */
Yann Collet88fcd292015-11-25 14:42:45 +0100375 ZBUFF_DCtx* dctx = ZBUFF_createDCtx();
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100376 FIO_getFileHandles(&finput, &foutput, input_filename, output_filename);
377
Yann Collet88fcd292015-11-25 14:42:45 +0100378 /* Allocate Memory (if needed) */
379 inBuff = (BYTE*)malloc(inBuffSize);
380 outBuff = (BYTE*)malloc(outBuffSize);
381 if (!inBuff || !outBuff) EXM_THROW(33, "Allocation error : not enough memory");
382
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100383 /* for each frame */
384 for ( ; ; )
385 {
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100386 U32 magicNumber;
Yann Collet88fcd292015-11-25 14:42:45 +0100387 toRead = 0;
388
389#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1)
390 /* check magic number -> version */
391 toRead = 4;
392 sizeCheck = fread(inBuff, (size_t)1, toRead, finput);
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100393 if (sizeCheck==0) break; /* no more input */
394 if (sizeCheck != toRead) EXM_THROW(31, "Read error : cannot read header");
Yann Collet88fcd292015-11-25 14:42:45 +0100395 magicNumber = MEM_readLE32(inBuff);
Yann Colletaa074052015-10-30 11:21:50 +0100396 if (ZSTD_isLegacy(magicNumber))
397 {
398 filesize += FIO_decompressLegacyFrame(foutput, finput, magicNumber);
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100399 continue;
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100400 }
Yann Colletaa074052015-10-30 11:21:50 +0100401#endif /* ZSTD_LEGACY_SUPPORT */
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100402
Yann Collet88fcd292015-11-25 14:42:45 +0100403 filesize += FIO_decompressFrame(foutput, finput, inBuff, inBuffSize, toRead, outBuff, outBuffSize, dctx);
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100404 }
405
406 DISPLAYLEVEL(2, "\r%79s\r", "");
407 DISPLAYLEVEL(2, "Decoded %llu bytes \n", (long long unsigned)filesize);
408
409 /* clean */
410 free(inBuff);
411 free(outBuff);
Yann Collet88fcd292015-11-25 14:42:45 +0100412 ZBUFF_freeDCtx(dctx);
Yann Colletb1f3f4b2015-10-18 22:18:32 +0100413 fclose(finput);
414 if (fclose(foutput)) EXM_THROW(38, "Write error : cannot properly close %s", output_filename);
415
416 return filesize;
417}
418
419