From 9cfc16ee38d1df4b1520f69452f900686f471c93 Mon Sep 17 00:00:00 2001 From: rh101 Date: Thu, 2 Sep 2021 20:43:37 +1000 Subject: [PATCH] Support 64 bit versions of posix lseek --- cocos/platform/CCPosixFileStream.cpp | 2 +- cocos/platform/CCPosixFileStream.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos/platform/CCPosixFileStream.cpp b/cocos/platform/CCPosixFileStream.cpp index cfff079c1a..a893c0f1e5 100644 --- a/cocos/platform/CCPosixFileStream.cpp +++ b/cocos/platform/CCPosixFileStream.cpp @@ -41,7 +41,7 @@ static int pfs_posix_open(const std::string& path, FileStream::Mode mode, PXFile // posix standard wrappers static int pfs_posix_read(PXFileHandle& handle, void* buf, unsigned int size) { return static_cast(posix_read(handle._fd, buf, size)); } -static off_t pfs_posix_seek(PXFileHandle& handle, off_t offst, int origin) { return posix_lseek(handle._fd, offst, origin); } +static off_t pfs_posix_seek(PXFileHandle& handle, off_t offst, int origin) { return posix_lseek64(handle._fd, offst, origin); } static int pfs_posix_close(PXFileHandle& handle) { int fd = handle._fd; if (fd != -1) { diff --git a/cocos/platform/CCPosixFileStream.h b/cocos/platform/CCPosixFileStream.h index f3624aaced..8fc06e22b7 100644 --- a/cocos/platform/CCPosixFileStream.h +++ b/cocos/platform/CCPosixFileStream.h @@ -36,11 +36,19 @@ #define posix_open(path, ...) ::_wopen(ntcvt::from_chars(path).c_str(), ##__VA_ARGS__) #define posix_close ::_close #define posix_lseek ::_lseek +#define posix_lseek64 ::_lseeki64 #define posix_read ::_read #define posix_write ::_write #define posix_fd2fh(fd) reinterpret_cast(_get_osfhandle(fd)) #define posix_fsetsize(fd, size) ::_chsize(fd, size) #else + +#if defined(__APPLE__) +# define posix_lseek64 ::lseek +#else +# define posix_lseek64 ::lseek64 +#endif + #define O_READ_FLAGS O_RDONLY #define O_WRITE_FLAGS O_CREAT | O_RDWR | O_TRUNC, S_IRWXU #define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU