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:
parent
5ae19de3ec
commit
5a9c6f26ab
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user