draco: Complete the large file support fix in the stdio reader.

Builds on the Windows-only fix added in
https://github.com/google/draco/pull/691
This commit is contained in:
Tom Finegan 2021-03-12 11:02:04 -08:00
parent 4469f97beb
commit 194b55a799
2 changed files with 11 additions and 5 deletions

View File

@ -63,6 +63,11 @@ macro(draco_set_build_definitions)
if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
else()
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
# Ensure 64-bit platforms can support large files.
list(APPEND draco_defines "_LARGEFILE_SOURCE" "_FILE_OFFSET_BITS=64")
endif()
endif()
if(ANDROID)

View File

@ -87,13 +87,14 @@ size_t StdioFileReader::GetFileSize() {
return false;
}
#if defined(_WIN64)
#if _FILE_OFFSET_BITS == 64
const size_t file_size = static_cast<size_t>(ftello(file_));
#elif defined _WIN64
const size_t file_size = static_cast<size_t>(_ftelli64(file_));
#else
const size_t file_size = static_cast<size_t>(ftell(file_));
#endif
rewind(file_);
return file_size;