Add type to deal with 64-bit filesizes on x86_64-apple-darwin15.5.0x86_64-apple-darwin15.5.0
parent
83b02ff41f
commit
0379675fca
|
@ -110,7 +110,7 @@ size_t DefaultIOStream::FileSize() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SIZE_MAX == cachedSize) {
|
if (SIZE_MAX == mCachedSize ) {
|
||||||
|
|
||||||
// Although fseek/ftell would allow us to reuse the existing file handle here,
|
// Although fseek/ftell would allow us to reuse the existing file handle here,
|
||||||
// it is generally unsafe because:
|
// it is generally unsafe because:
|
||||||
|
@ -125,18 +125,19 @@ size_t DefaultIOStream::FileSize() const
|
||||||
int err = _stat64( mFilename.c_str(), &fileStat );
|
int err = _stat64( mFilename.c_str(), &fileStat );
|
||||||
if (0 != err)
|
if (0 != err)
|
||||||
return 0;
|
return 0;
|
||||||
cachedSize = (size_t) (fileStat.st_size);
|
mCachedSize = (size_t) (fileStat.st_size);
|
||||||
#elif defined __gnu_linux__ || defined __APPLE__ || defined __MACH__
|
#elif defined __gnu_linux__ || defined __APPLE__ || defined __MACH__
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(mFilename.c_str(), &fileStat );
|
int err = stat(mFilename.c_str(), &fileStat );
|
||||||
if (0 != err)
|
if (0 != err)
|
||||||
return 0;
|
return 0;
|
||||||
cachedSize = (size_t) (fileStat.st_size);
|
const unsigned long long cachedSize = fileStat.st_size;
|
||||||
|
mCachedSize = static_cast< size_t >( cachedSize );
|
||||||
#else
|
#else
|
||||||
# error "Unknown platform"
|
# error "Unknown platform"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return cachedSize;
|
return mCachedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -111,7 +111,7 @@ private:
|
||||||
std::string mFilename;
|
std::string mFilename;
|
||||||
|
|
||||||
// Cached file size
|
// Cached file size
|
||||||
mutable size_t cachedSize;
|
mutable size_t mCachedSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ private:
|
||||||
inline DefaultIOStream::DefaultIOStream () :
|
inline DefaultIOStream::DefaultIOStream () :
|
||||||
mFile (NULL),
|
mFile (NULL),
|
||||||
mFilename (""),
|
mFilename (""),
|
||||||
cachedSize (SIZE_MAX)
|
mCachedSize(SIZE_MAX)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ inline DefaultIOStream::DefaultIOStream (FILE* pFile,
|
||||||
const std::string &strFilename) :
|
const std::string &strFilename) :
|
||||||
mFile(pFile),
|
mFile(pFile),
|
||||||
mFilename(strFilename),
|
mFilename(strFilename),
|
||||||
cachedSize (SIZE_MAX)
|
mCachedSize(SIZE_MAX)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue