diff options
author | kaliamoorthi@chromium.org <kaliamoorthi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-27 12:54:32 +0000 |
---|---|---|
committer | kaliamoorthi@chromium.org <kaliamoorthi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-27 12:54:32 +0000 |
commit | d0c382d108aea041fc6eb8861f8cda0574c2c0fe (patch) | |
tree | d49db039dc6478ce49770430d909cf4d30a4110b /base/file_util.h | |
parent | 56f66b18db5dcc9024dd0f287ff6601995121273 (diff) | |
download | chromium_src-d0c382d108aea041fc6eb8861f8cda0574c2c0fe.zip chromium_src-d0c382d108aea041fc6eb8861f8cda0574c2c0fe.tar.gz chromium_src-d0c382d108aea041fc6eb8861f8cda0574c2c0fe.tar.bz2 |
Followup to modifications to ReadFileToString function
This CL cleans up the changes done as part of https://codereview.chromium.org/157593005/
A minor change is done to the unit test along with some changes to the API documentation in the header.
BUG=339417
Review URL: https://codereview.chromium.org/177073018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.h')
-rw-r--r-- | base/file_util.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/base/file_util.h b/base/file_util.h index 4c25b3a..4af6c97 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -136,23 +136,22 @@ BASE_EXPORT bool ContentsEqual(const FilePath& filename1, BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2); -// Read the file at |path| into |contents|, returning true on success. -// This function fails if the |path| contains path traversal components ('..'). +// Reads the file at |path| into |contents| and returns true on success. // |contents| may be NULL, in which case this function is useful for its -// side effect of priming the disk cache, which is useful for unit tests. -// The function replaces rather than append to |contents|, further |contents| -// could be cleared on error. +// side effect of priming the disk cache (could be used for unit tests). +// The function returns false and the string pointed to by |contents| is +// cleared when |path| does not exist or if it contains path traversal +// components ('..'). BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents); -// Read the file at |path| into |contents|, returning true on success. -// This function has an additional check on the maximum size of the file. -// When the file size is greater than |max_size|, the function reads |max_size| -// bytes into |contents| and returns false. -// This function fails if the |path| contains path traversal components ('..'). +// Reads the file at |path| into |contents| and returns true on success. // |contents| may be NULL, in which case this function is useful for its -// side effect of priming the disk cache, which is useful for unit tests. -// The function replaces rather than append to |contents|, further |contents| -// could be cleared on error. +// side effect of priming the disk cache (could be used for unit tests). +// The function returns false and the string pointed to by |contents| is +// cleared when |path| does not exist or if it contains path traversal +// components ('..'). +// When the file size exceeds |max_size|, the function returns false +// with |contents| holding the file truncated to |max_size|. BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents, size_t max_size); |