Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1978)

Unified Diff: net/base/file_stream_posix.cc

Issue 21363: Adds a new method ReadUntilComplete to FileStream which ensure that a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/file_stream_posix.cc
===================================================================
--- net/base/file_stream_posix.cc (revision 9711)
+++ net/base/file_stream_posix.cc (working copy)
@@ -154,6 +154,27 @@
}
}
+int FileStream::ReadUntilComplete(char *buf, int buf_len) {
+ int to_read = buf_len;
+ int bytes_total = 0;
+
+ do {
+ int bytes_read = Read(buf, to_read, NULL);
+ if (bytes_read <= 0) {
+ if (bytes_total == 0)
+ return bytes_read;
+
+ return bytes_total;
+ }
+
+ bytes_total += bytes_read;
+ buf += bytes_read;
+ to_read -= bytes_read;
+ } while (bytes_total < buf_len);
+
+ return bytes_total;
+}
+
// TODO(deanm): async.
int FileStream::Write(
const char* buf, int buf_len, CompletionCallback* callback) {
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698