This commit is contained in:
@@ -55,6 +55,7 @@ DefaultIOStream::~DefaultIOStream()
|
||||
{
|
||||
if (mFile) {
|
||||
::fclose(mFile);
|
||||
mFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ size_t DefaultIOStream::FileSize() const
|
||||
|
||||
if (SIZE_MAX == cachedSize) {
|
||||
|
||||
// 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
|
||||
@@ -125,12 +126,14 @@ size_t DefaultIOStream::FileSize() const
|
||||
if (0 != err)
|
||||
return 0;
|
||||
cachedSize = (size_t) (fileStat.st_size);
|
||||
#else
|
||||
#elif defined __gnu_linux__
|
||||
struct stat fileStat;
|
||||
int err = stat(mFilename.c_str(), &fileStat );
|
||||
if (0 != err)
|
||||
return 0;
|
||||
cachedSize = (size_t) (fileStat.st_size);
|
||||
#else
|
||||
# error "Unknown platform"
|
||||
#endif
|
||||
}
|
||||
return cachedSize;
|
||||
|
||||
Reference in New Issue
Block a user