From d9fbb1bc814726c13ee22669309e7a5bc6d17bc1 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Fri, 28 Jan 2000 21:42:48 +0000 Subject: [PATCH] Applied changes for seek allowing 2-4GB seeks. --- libtiff/tif_win32.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c index 296437eb..1a3afa1c 100644 --- a/libtiff/tif_win32.c +++ b/libtiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.4 1999-11-27 21:43:59 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.5 2000-01-28 21:42:48 warmerda Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -52,23 +52,30 @@ _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { - DWORD dwMoveMethod; + DWORD dwMoveMethod, dwMoveHigh; + + /* we use this as a special code, so avoid accepting it */ + if( off == 0xFFFFFFFF ) + return 0xFFFFFFFF; + switch(whence) { - case 0: + case SEEK_SET: dwMoveMethod = FILE_BEGIN; break; - case 1: + case SEEK_CUR: dwMoveMethod = FILE_CURRENT; break; - case 2: + case SEEK_END: dwMoveMethod = FILE_END; break; default: dwMoveMethod = FILE_BEGIN; break; } - return ((toff_t)SetFilePointer(fd, off, NULL, dwMoveMethod)); + dwMoveHigh = 0; + return ((toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh, + dwMoveMethod)); } static int @@ -109,7 +116,7 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) toff_t size; HANDLE hMapFile; - if ((size = _tiffSizeProc(fd)) == (toff_t)-1) + if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF) return (0); hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL); if (hMapFile == NULL)