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

Unified Diff: base/file_util_posix.cc

Issue 240893002: base::ReadFile() should return the number of read bytes on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing parenthesis. Created 6 years, 8 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
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index e2eb2f89ac09464bdb817c9798740b2979d149d3..73de948f6f65470f07d7877898956fcce03a4698 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -651,13 +651,13 @@ FILE* OpenFile(const FilePath& filename, const char* mode) {
return result;
}
-int ReadFile(const FilePath& filename, char* data, int size) {
+int ReadFile(const FilePath& filename, char* data, int max_size) {
ThreadRestrictions::AssertIOAllowed();
int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY));
if (fd < 0)
return -1;
- ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size));
+ ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size));
Mark Mentovai 2014/04/17 16:21:57 I kinda feel like if this was a short read but EOF
fukino 2014/04/18 02:22:12 Thank you for suggestion! I didn't realize any cas
if (int ret = IGNORE_EINTR(close(fd)) < 0)
Mark Mentovai 2014/04/17 16:21:57 You don’t need to track |ret| here, you can just
fukino 2014/04/18 02:22:12 Done for ReadFile(), WriteFile() and AppendToFile(
return ret;
return bytes_read;
« no previous file with comments | « base/file_util.h ('k') | base/file_util_unittest.cc » ('j') | base/file_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698