summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-03-13 21:15:08 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-03-13 21:15:08 (GMT)
commit248b761f55b92a34eacbfe2ac5d6f1b94e69d7bf (patch)
tree8c4ffae8d5fa9af6f9028f0e397fc8aa1f74d7af /programs
parentd11ac4087254db4b9391039ce862e7305874fe97 (diff)
downloadlz4-248b761f55b92a34eacbfe2ac5d6f1b94e69d7bf.zip
lz4-248b761f55b92a34eacbfe2ac5d6f1b94e69d7bf.tar.gz
lz4-248b761f55b92a34eacbfe2ac5d6f1b94e69d7bf.tar.bz2
windows sparse file support
Diffstat (limited to 'programs')
-rwxr-xr-x[-rw-r--r--]programs/lz4io.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 762bdb5..94bf5ea 100644..100755
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -56,22 +56,25 @@
#include "lz4frame.h"
-/*****************************
+/******************************
* OS-specific Includes
-*****************************/
+******************************/
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
# include <fcntl.h> /* _O_BINARY */
-# include <io.h> /* _setmode, _fileno */
+# include <io.h> /* _setmode, _fileno, _get_osfhandle */
# define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
+# include <Windows.h> /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */
+# define SET_SPARSE_FILE_MODE(file) { DWORD dw; DeviceIoControl((HANDLE) _get_osfhandle(_fileno(file)), FSCTL_SET_SPARSE, 0, 0, 0, 0, &dw, 0); }
# if defined(_MSC_VER) && (_MSC_VER >= 1400) /* Avoid MSVC fseek()'s 2GiB barrier */
# define fseek _fseeki64
# endif
#else
# define SET_BINARY_MODE(file)
+# define SET_SPARSE_FILE_MODE(file)
#endif
-/****************************
+/*****************************
* Constants
*****************************/
#define KB *(1 <<10)
@@ -607,7 +610,7 @@ static unsigned long long decodeLZ4S(FILE* finput, FILE* foutput)
static const size_t zeroBlockSize = 32 KB;
while (oBuffPos < oBuffEnd)
{
- size_t* sPtr = (size_t*)oBuffPos;
+ const size_t* sPtr = (const size_t*)oBuffPos;
size_t seg0Size = zeroBlockSize;
size_t nbSizeT;
size_t checked;
@@ -717,6 +720,12 @@ int LZ4IO_decompressFilename(const char* input_filename, const char* output_file
start = clock();
get_fileHandle(input_filename, output_filename, &finput, &foutput);
+ /* sparse file */
+ if (g_sparseFileSupport && foutput)
+ {
+ SET_SPARSE_FILE_MODE(foutput);
+ }
+
/* Loop over multiple streams */
do
{