Restore behavior to FileWrapper::Read.
- Returning the number of bytes read was mistakenly removed in r1175 in
an overzealous attempt to unify the interface.
- Now both Read and WriteText return the number of bytes/characters
processed. Write unfortunately cannot be easily changed due to the
inheritance from OutStream.
- Improve the interface comments.
TBR=henrika@webrtc.org
BUG=issue196, issue198
TEST=voe_auto_test passes at last...
Review URL: http://webrtc-codereview.appspot.com/326001
git-svn-id: http://webrtc.googlecode.com/svn/trunk@1188 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/src/system_wrappers/source/file_impl.cc b/src/system_wrappers/source/file_impl.cc
index c58d419..67a4567 100644
--- a/src/system_wrappers/source/file_impl.cc
+++ b/src/system_wrappers/source/file_impl.cc
@@ -188,6 +188,10 @@
int FileWrapperImpl::Read(void *buf, int len)
{
+ if (len < 0)
+ {
+ return -1;
+ }
if (_id != NULL)
{
int res = static_cast<int>(fread(buf, 1, len, _id));
@@ -198,7 +202,7 @@
CloseFile();
}
}
- return 0;
+ return res;
}
return -1;
}
@@ -219,9 +223,9 @@
int num_chars = vfprintf(_id, format, args);
va_end(args);
- if (num_chars > 0)
+ if (num_chars >= 0)
{
- return 0;
+ return num_chars;
}
else
{