From 8ee54741e1e1d808fb584d5395fa977f70a337f4 Mon Sep 17 00:00:00 2001 From: henrikbuchholz Date: Wed, 14 Aug 2013 16:08:09 +0200 Subject: [PATCH] DefaultIOStream::FileSize(): Replaced windows-based version to use mFile directly instead of fileStat Unfortunately, it is not 100% clear anymore what's the background of this change. Maybe it was faster or it avoided issues in case that file loaders used exclusive open. All I know is that this change is not the accidental result of a merge, because according to SVN blame, this code section had never been touched since revision 1. So it must have been done for InfraWorks for some reason. So I preserved this change to avoid regression due to the AssImp update. --- code/DefaultIOStream.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index 9f9a3de78..cabbe6b33 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -112,11 +112,11 @@ size_t DefaultIOStream::FileSize() const // TODO: Is that really faster if we're already owning a handle to the file? #if defined _WIN32 && !defined __GNUC__ - struct __stat64 fileStat; - int err = _stat64( mFilename.c_str(), &fileStat ); - if (0 != err) - return 0; - cachedSize = (size_t) (fileStat.st_size); + + int current = ::ftell(mFile); + ::fseek(mFile, 0, SEEK_END); + cachedSize = (size_t)::ftell(mFile); + ::fseek(mFile, current, SEEK_SET); #else struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat );