From 96fe545a18b4f69cae28749bfcc304c54705959a Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Fri, 31 Mar 2017 15:16:43 -0700 Subject: [PATCH 1/2] Turn off sparse mode for OS X by default --- programs/fileio.c | 3 +++ programs/platform.h | 8 ++++++++ programs/zstdcli.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/programs/fileio.c b/programs/fileio.c index 572e9c9a..87871ae0 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -227,6 +227,9 @@ static FILE* FIO_openDstFile(const char* dstFileName) DISPLAYLEVEL(4, "Sparse File Support is automatically disabled on stdout ; try --sparse \n"); } } else { + if (ZSTD_SPARSE_DEFAULT == 0 && g_sparseFileSupport == 1) { + g_sparseFileSupport = 0; + } if (!g_overwrite && strcmp (dstFileName, nulmark)) { /* Check if destination file already exists */ f = fopen( dstFileName, "rb" ); if (f != 0) { /* dest file exists, prompt for overwrite authorization */ diff --git a/programs/platform.h b/programs/platform.h index ee781951..74412cde 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -138,6 +138,14 @@ static __inline int IS_CONSOLE(FILE* stdStream) #endif +#ifndef ZSTD_SPARSE_DEFAULT +# if (defined(__APPLE__) && defined(__MACH__)) +# define ZSTD_SPARSE_DEFAULT 0 +# else +# define ZSTD_SPARSE_DEFAULT 1 +# endif +#endif + #if defined (__cplusplus) } diff --git a/programs/zstdcli.c b/programs/zstdcli.c index e2709ec8..0cf8cacd 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -137,7 +137,11 @@ static int usage_advanced(const char* programName) #endif #ifndef ZSTD_NODECOMPRESS DISPLAY( "--test : test compressed file integrity \n"); +#if ZSTD_SPARSE_DEFAULT DISPLAY( "--[no-]sparse : sparse mode (default:enabled on file, disabled on stdout)\n"); +#else + DISPLAY( "--[no-]sparse : sparse mode (default:disabled)\n"); +#endif #endif DISPLAY( " -M# : Set a memory usage limit for decompression \n"); DISPLAY( "-- : All arguments after \"--\" are treated as files \n"); From eb38617175351bfaf933bc75a6604e070128ca79 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Fri, 31 Mar 2017 15:20:50 -0700 Subject: [PATCH 2/2] Clean up default sparse logic --- programs/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 87871ae0..78fb9a26 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -227,8 +227,8 @@ static FILE* FIO_openDstFile(const char* dstFileName) DISPLAYLEVEL(4, "Sparse File Support is automatically disabled on stdout ; try --sparse \n"); } } else { - if (ZSTD_SPARSE_DEFAULT == 0 && g_sparseFileSupport == 1) { - g_sparseFileSupport = 0; + if (g_sparseFileSupport == 1) { + g_sparseFileSupport = ZSTD_SPARSE_DEFAULT; } if (!g_overwrite && strcmp (dstFileName, nulmark)) { /* Check if destination file already exists */ f = fopen( dstFileName, "rb" );