Skip to content

Commit

Permalink
WIP, support of large attribute arrays in geofile (> 4Gb) (#223)
Browse files Browse the repository at this point in the history
Fallbacks for Windows and MacOS (for now)
  • Loading branch information
BrunoLevy committed Feb 9, 2025
1 parent 93adbf9 commit 1f5dff0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/lib/geogram/basic/geofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ namespace {
/** \brief Maximum length of a gzlib gzread() or gzwrite() */
static constexpr GEO::Numeric::uint32 MAX_GZ_IO_SIZE = 1024*1024*1024;

#ifdef GEO_OS_LINUX

/**
* \brief Wrapper around gzread() to read more than 4Gb
*/
Expand Down Expand Up @@ -153,6 +155,32 @@ namespace {
return ssize_t(bytes_read);
}

#else

ssize_t gzread64(gzFile file, void* buf_in, size_t len) {
geo_assert(len < size_t(MAX_GZ_IO_SIZE));
return ssize_t(gzread(file, buf_in, long(len)));
}

ssize_t gzwrite64(gzFile file, const void* buf_in, size_t len) {
geo_assert(len < size_t(MAX_GZ_IO_SIZE));
return ssize_t(gzwrite(file, buf_in, long(len)));
}

ssize_t gztell64(gzFile file) {
return ssize_t(gztell(file));
}

ssize_t gzseek64(gzFile file, ssize_t off, int whence) {
geo_assert(
off >= -ssize_t(MAX_GZ_IO_SIZE) && off <= ssize_t(MAX_GZ_IO_SIZE)
);
return ssize_t gzseek(file, z_off_t(off), whence);
}



#endif

}

Expand Down

0 comments on commit 1f5dff0

Please sign in to comment.