@@ -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];