From 98be008479486f60b0a98289eee2f57c28650964 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Mon, 7 Nov 2016 12:41:14 +0100 Subject: Copy owner, file permissions and modification time --- programs/lz4io.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/programs/lz4io.c b/programs/lz4io.c index 2f64561..73ca27e 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -33,14 +33,7 @@ /************************************** * Compiler Options **************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define _CRT_SECURE_NO_WARNINGS -# define _CRT_SECURE_NO_DEPRECATE /* VS2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -#endif - #define _LARGE_FILES /* Large file support on 32-bits AIX */ -#define _FILE_OFFSET_BITS 64 /* Large file support on 32-bits unix */ #if defined(__MINGW32__) && !defined(_POSIX_SOURCE) # define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */ @@ -49,6 +42,7 @@ /***************************** * Includes *****************************/ +#include "util.h" /* Compiler options, UTIL_getFileStat */ #include /* fprintf, fopen, fread, stdin, stdout, fflush, getchar */ #include /* malloc, free */ #include /* strcmp, strlen */ @@ -464,12 +458,14 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, size_t readSize; LZ4F_compressionContext_t ctx = ress.ctx; /* just a pointer */ LZ4F_preferences_t prefs; - + stat_t statbuf; + int stat_result = 0; /* Init */ memset(&prefs, 0, sizeof(prefs)); /* File check */ + if (strcmp (srcFileName, stdinmark) && UTIL_getFileStat(srcFileName, &statbuf)) stat_result = 1; if (LZ4IO_getFiles(srcFileName, dstFileName, &srcFile, &dstFile)) return 1; /* Set compression parameters */ @@ -547,6 +543,9 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName, fclose (srcFile); fclose (dstFile); + /* Copy owner, file permissions and modification time */ + if (strcmp (dstFileName, stdoutmark) && stat_result) UTIL_setFileStat(dstFileName, &statbuf); + /* Final Status */ DISPLAYLEVEL(2, "\r%79s\r", ""); DISPLAYLEVEL(2, "Compressed %llu bytes into %llu bytes ==> %.2f%%\n", -- cgit v0.12