Fix max size and read-only errors in Write().

- A size of zero is now correctly interpreted as unlimited.
- The read-only flag is correctly checked.

TBR=henrika@webrtc.org
TEST=vie_auto_test (for real this time...)

Review URL: http://webrtc-codereview.appspot.com/315007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1176 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2011-12-14 00:53:30 +00:00
parent 5ae19de3ec
commit 5a9c6f26ab
2 changed files with 4 additions and 3 deletions

View File

@ -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.

View File

@ -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;