diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-09-09 17:05:38 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-09-09 17:05:38 (GMT) |
commit | 0babbf966b043a085303889fba4471b02f75cd14 (patch) | |
tree | a04b2c10d34d07803c3b87c61dd8ab5c5686f3c1 /generic/tclZipfs.c | |
parent | b8d2426e1bcc860c2c743e2baebbd9c57f117bb9 (diff) | |
download | tcl-0babbf966b043a085303889fba4471b02f75cd14.zip tcl-0babbf966b043a085303889fba4471b02f75cd14.tar.gz tcl-0babbf966b043a085303889fba4471b02f75cd14.tar.bz2 |
slightly better: Use GetFileSizeEx() on win64 and GetFileSize on win32
Diffstat (limited to 'generic/tclZipfs.c')
-rw-r--r-- | generic/tclZipfs.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 4d716df..c65b1a6 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -172,7 +172,7 @@ typedef struct ZipFile { char is_membuf; /* When true, not a file but a memory buffer */ Tcl_Channel chan; /* Channel handle or NULL */ unsigned char *data; /* Memory mapped or malloc'ed file */ - Tcl_WideUInt length; /* Length of memory mapped file */ + size_t length; /* Length of memory mapped file */ unsigned char *tofree; /* Non-NULL if malloc'ed file */ size_t nfiles; /* Number of files in archive */ size_t baseoffs; /* Archive start */ @@ -1057,10 +1057,16 @@ ZipFSOpenArchive(Tcl_Interp *interp, const char *zipname, int needZip, ZipFile * Tcl_Close(interp, zf->chan); zf->chan = NULL; } else { -#if defined(_WIN32) || defined(_WIN64) +#ifdef _WIN32) +# ifdef _WIN64 i = GetFileSizeEx((HANDLE) handle, (PLARGE_INTEGER)&zf->length); if ( (i == 0) || +# else + zf->length = GetFileSize((HANDLE) handle, 0); + if ( + (zf->length == (size_t)INVALID_FILE_SIZE) || +# endif (zf->length < ZIP_CENTRAL_END_LEN) ) { ZIPFS_ERROR(interp,"invalid file size"); |