diff options
Diffstat (limited to 'src/3rdparty/assimp/code/DefaultIOStream.cpp')
-rw-r--r-- | src/3rdparty/assimp/code/DefaultIOStream.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/3rdparty/assimp/code/DefaultIOStream.cpp b/src/3rdparty/assimp/code/DefaultIOStream.cpp index f1809d894..cce9af19d 100644 --- a/src/3rdparty/assimp/code/DefaultIOStream.cpp +++ b/src/3rdparty/assimp/code/DefaultIOStream.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2016, assimp team +Copyright (c) 2006-2017, assimp team + All rights reserved. @@ -44,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <assimp/ai_assert.h> -#include "DefaultIOStream.h" +#include <assimp/DefaultIOStream.h> #include <sys/types.h> #include <sys/stat.h> @@ -55,6 +56,7 @@ DefaultIOStream::~DefaultIOStream() { if (mFile) { ::fclose(mFile); + mFile = nullptr; } } @@ -109,9 +111,9 @@ size_t DefaultIOStream::FileSize() const return 0; } - if (SIZE_MAX == cachedSize) { + if (SIZE_MAX == mCachedSize ) { - // Although fseek/ftell would allow us to reuse the exising file handle here, + // Although fseek/ftell would allow us to reuse the existing file handle here, // it is generally unsafe because: // - For binary streams, it is not technically well-defined // - For text files the results are meaningless @@ -119,21 +121,24 @@ size_t DefaultIOStream::FileSize() const // // See here for details: // https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file -#if defined _WIN32 && !defined __GNUC__ +#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) struct __stat64 fileStat; int err = _stat64( mFilename.c_str(), &fileStat ); if (0 != err) return 0; - cachedSize = (size_t) (fileStat.st_size); -#else + mCachedSize = (size_t) (fileStat.st_size); +#elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__ struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat ); if (0 != err) return 0; - cachedSize = (size_t) (fileStat.st_size); + const unsigned long long cachedSize = fileStat.st_size; + mCachedSize = static_cast< size_t >( cachedSize ); +#else +# error "Unknown platform" #endif } - return cachedSize; + return mCachedSize; } // ---------------------------------------------------------------------------------- |