diff --git a/src/system_wrappers/interface/file_wrapper.h b/src/system_wrappers/interface/file_wrapper.h index d8112ee6d2..71f945aee9 100644 --- a/src/system_wrappers/interface/file_wrapper.h +++ b/src/system_wrappers/interface/file_wrapper.h @@ -40,7 +40,8 @@ public: virtual int CloseFile() = 0; - // Limits the file size. + // Limits the file size to |bytes|. Writing will fail after the cap + // is hit. Pass zero to use an unlimited size. virtual int SetMaxFileSize(size_t bytes) = 0; // Flush any pending writes. diff --git a/src/system_wrappers/source/file_impl.cc b/src/system_wrappers/source/file_impl.cc index 3fc913707f..c58d419168 100644 --- a/src/system_wrappers/source/file_impl.cc +++ b/src/system_wrappers/source/file_impl.cc @@ -232,7 +232,7 @@ int FileWrapperImpl::WriteText(const char* format, ...) bool FileWrapperImpl::Write(const void* buf, int len) { - if (!_readOnly) + if (_readOnly) { return false; } @@ -240,7 +240,7 @@ bool FileWrapperImpl::Write(const void* buf, int len) if (_id != NULL) { // Check if it's time to stop writing. - if (_sizeInBytes + len > _maxSizeInBytes) + if (_maxSizeInBytes > 0 && (_sizeInBytes + len) > _maxSizeInBytes) { Flush(); return false;