Support 64 bit versions of posix lseek

This commit is contained in:
rh101 2021-09-02 20:43:37 +10:00
parent 568e3612bd
commit 9cfc16ee38
2 changed files with 9 additions and 1 deletions

View File

@ -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<int>(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) {

View File

@ -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<HANDLE>(_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