diff options
author | Przemyslaw Skibinski <inikep@gmail.com> | 2016-11-07 11:41:14 (GMT) |
---|---|---|
committer | Przemyslaw Skibinski <inikep@gmail.com> | 2016-11-07 11:41:14 (GMT) |
commit | 98be008479486f60b0a98289eee2f57c28650964 (patch) | |
tree | 91c9736e7aac5ce578356f02694028621d823ce1 /programs | |
parent | 1581567299d150504eae3e08c44dcdfec78008e6 (diff) | |
download | lz4-98be008479486f60b0a98289eee2f57c28650964.zip lz4-98be008479486f60b0a98289eee2f57c28650964.tar.gz lz4-98be008479486f60b0a98289eee2f57c28650964.tar.bz2 |
Copy owner, file permissions and modification time
Diffstat (limited to 'programs')
-rw-r--r-- | programs/lz4io.c | 15 |
1 files 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 <stdio.h> /* fprintf, fopen, fread, stdin, stdout, fflush, getchar */ #include <stdlib.h> /* malloc, free */ #include <string.h> /* 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", |