Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -693,10 +693,14 @@ AS_IF([test x"$enable_files" != x"no"], [ AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files]) AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(OFHASH, "ofhash") AC_SUBST(OFZIP, "ofzip") + + AC_CHECK_TYPE(off64_t, [ + AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t]) + ]) AC_CHECK_FUNCS(readdir_r) ]) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep lstat]) Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -27,14 +27,16 @@ #import "OFSeekableStream.h" @class OFArray; @class OFDate; -#ifndef _WIN32 -typedef struct stat of_stat_t; +#if defined(_WIN32) +typedef struct __stat64 of_stat_t; +#elif defined(OF_HAVE_OFF64_T) +typedef struct stat64 of_stat_t; #else -typedef struct _stat of_stat_t; +typedef struct stat of_stat_t; #endif /*! * @class OFFile OFFile.h ObjFW/OFFile.h * Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -124,12 +124,15 @@ #endif int of_stat(OFString *path, of_stat_t *buffer) { -#ifdef _WIN32 - return _wstat([path UTF16String], buffer); +#if defined(_WIN32) + return _wstat64([path UTF16String], buffer); +#elif defined(OF_HAVE_OFF64_T) + return stat64([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); #else return stat([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], buffer); #endif } @@ -136,17 +139,27 @@ int of_lstat(OFString *path, of_stat_t *buffer) { #if defined(_WIN32) - return _wstat([path UTF16String], buffer); + return _wstat64([path UTF16String], buffer); #elif defined(HAVE_LSTAT) +# ifdef OF_HAVE_OFF64_T + return lstat64([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); +# else return lstat([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], buffer); +# endif #else +# ifdef OF_HAVE_OFF64_T + return stat64([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); +# else return stat([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], buffer); +# endif #endif } static int parseMode(const char *mode) @@ -893,16 +906,19 @@ if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_CLOEXEC; -#ifndef _WIN32 - if ((_fd = open([path cStringWithEncoding: [OFSystemInfo +#if defined(_WIN32) + if ((_fd = _wopen([path UTF16String], flags, + DEFAULT_MODE)) == -1) +#elif defined(OF_HAVE_OFF64_T) + if ((_fd = open64([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], flags, DEFAULT_MODE)) == -1) #else - if ((_fd = _wopen([path UTF16String], flags, - DEFAULT_MODE)) == -1) + if ((_fd = open([path cStringWithEncoding: [OFSystemInfo + native8BitEncoding]], flags, DEFAULT_MODE)) == -1) #endif @throw [OFOpenFileFailedException exceptionWithPath: path mode: mode]; } @catch (id e) { @@ -975,11 +991,17 @@ } - (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence { +#if defined(_WIN32) + of_offset_t ret = _lseeki64(_fd, offset, whence); +#elif defined(OF_HAVE_OFF64_T) + of_offset_t ret = lseek64(_fd, offset, whence); +#else of_offset_t ret = lseek(_fd, offset, whence); +#endif if (ret == -1) @throw [OFSeekFailedException exceptionWithStream: self offset: offset whence: whence]; Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -23,12 +23,16 @@ #include #import "OFStream.h" -#ifdef __ANDROID__ +#if defined(_WIN32) +typedef __int64 of_offset_t; +#elif defined(__ANDROID__) typedef long long of_offset_t; +#elif defined(OF_HAVE_OFF64_T) +typedef off64_t of_offset_t; #else typedef off_t of_offset_t; #endif /*!