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

Issue 240893002: base::ReadFile() should return the number of read bytes on Windows. (Closed)

Created:
6 years, 8 months ago by fukino
Modified:
6 years, 8 months ago
Reviewers:
Mark Mentovai
CC:
chromium-reviews, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

base::ReadFile() should return the number of read bytes on Windows. base::ReadFile() has inconsistent behavior between Linux/Mac and Windows. When the passed |size| argument is larger than file's size, ReadFile() on Linux/Mac returns the number of read bytes, but ReadFile() on Windows returns -1. We can workaround this behavior by calling GetFileSize() first, but there are already many clients which treat |size| as max size (They're passing the size of buffer). I think we should make behavior on Windows be consistent with Linux/Mac. BUG=243885 TEST=run base_unittests Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=264768

Patch Set 1 : Add unit test which intentionally make try bot on Windows fail. #

Patch Set 2 : Return the number of read bytes from ReadFile on Windows. #

Patch Set 3 : Add missing parenthesis. #

Total comments: 10

Patch Set 4 : Correct comments and how to return value on error cases. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+60 lines, -14 lines) Patch
M base/file_util.h View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M base/file_util_posix.cc View 1 2 3 3 chunks +8 lines, -8 lines 0 comments Download
M base/file_util_unittest.cc View 1 2 3 2 chunks +46 lines, -0 lines 0 comments Download
M base/file_util_win.cc View 1 2 2 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
fukino
Hi Mark, Could you take a look?
6 years, 8 months ago (2014-04-17 13:12:18 UTC) #1
Mark Mentovai
LGTM to your change, but consider this additional improvement. https://codereview.chromium.org/240893002/diff/40001/base/file_util_posix.cc File base/file_util_posix.cc (right): https://codereview.chromium.org/240893002/diff/40001/base/file_util_posix.cc#newcode660 base/file_util_posix.cc:660: ...
6 years, 8 months ago (2014-04-17 16:21:57 UTC) #2
fukino
https://codereview.chromium.org/240893002/diff/40001/base/file_util_posix.cc File base/file_util_posix.cc (right): https://codereview.chromium.org/240893002/diff/40001/base/file_util_posix.cc#newcode660 base/file_util_posix.cc:660: ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size)); On 2014/04/17 16:21:57, ...
6 years, 8 months ago (2014-04-18 02:22:12 UTC) #3
fukino
The CQ bit was checked by fukino@chromium.org
6 years, 8 months ago (2014-04-18 03:23:08 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/fukino@chromium.org/240893002/60001
6 years, 8 months ago (2014-04-18 03:23:41 UTC) #5
commit-bot: I haz the power
6 years, 8 months ago (2014-04-18 10:34:19 UTC) #6
Message was sent while issue was closed.
Change committed as 264768

Powered by Google App Engine
This is Rietveld 408576698