From 9849c6b8479f18d983eadd58d7ba6f9feaaa8f6a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 22 Aug 2008 18:09:03 +0000 Subject: Adjustments to better select/differentiate when large/small file support is provided using WIN32 functions directly. --- src/config-win32.h | 16 ++++++++++++++++ src/main.c | 32 +++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/config-win32.h b/src/config-win32.h index 84a16fdc8..654d892d8 100644 --- a/src/config-win32.h +++ b/src/config-win32.h @@ -235,6 +235,22 @@ # endif #endif +/* ---------------------------------------------------------------- */ +/* LARGE FILE SUPPORT */ +/* ---------------------------------------------------------------- */ + +#if defined(_MSC_VER) && !defined(_WIN32_WCE) +# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) +# define USE_WIN32_LARGE_FILES +# else +# define USE_WIN32_SMALL_FILES +# endif +#endif + +#if !defined(USE_WIN32_LARGE_FILES) && !defined(USE_WIN32_SMALL_FILES) +# define USE_WIN32_SMALL_FILES +#endif + /* ---------------------------------------------------------------- */ /* ADDITIONAL DEFINITIONS */ /* ---------------------------------------------------------------- */ diff --git a/src/main.c b/src/main.c index b70219189..6c149cfb6 100644 --- a/src/main.c +++ b/src/main.c @@ -210,14 +210,32 @@ typedef enum { #include "curlmsg_vms.h" #endif -/* Support uploading and resuming of >2GB files +/* + * Large file support (>2Gb) using WIN32 functions. */ -#if defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T > 4) -#define lseek(x,y,z) _lseeki64(x, y, z) -#define struct_stat struct _stati64 -#define stat(file,st) _stati64(file,st) -#else -#define struct_stat struct stat + +#ifdef USE_WIN32_LARGE_FILES +# include +# include +# include +# define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) +# define fstat(fdes,stp) _fstati64(fdes, stp) +# define stat(fname,stp) _stati64(fname, stp) +# define struct_stat struct _stati64 +#endif + +/* + * Small file support (<2Gb) using WIN32 functions. + */ + +#ifdef USE_WIN32_SMALL_FILES +# include +# include +# include +# define lseek(fdes,offset,whence) _lseek(fdes, offset, whence) +# define fstat(fdes,stp) _fstat(fdes, stp) +# define stat(fname,stp) _stat(fname, stp) +# define struct_stat struct _stat #endif #ifdef CURL_DOES_CONVERSIONS -- cgit v1.2.3