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

Unified Diff: base/file_util.h

Issue 157593005: Added new ReadFileToString API with a max_size argument (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new ReadFileToString API with a max_size argument Created 6 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 | « no previous file | base/file_util.cc » ('j') | base/file_util.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.h
diff --git a/base/file_util.h b/base/file_util.h
index f8418318a6a7ecd92255e6d708624b7f1ae6bcf7..1b67d6a231b868dbfbf09a7beb7bca10f58b1770 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -137,6 +137,14 @@ BASE_EXPORT bool TextContentsEqual(const FilePath& filename1,
// Useful for unit tests.
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 |maxsize|, the function returns false
+// with |contents| pointing to empty string.
bartfab (slow) 2014/02/11 12:51:12 Nit: s/to empty/to an empty/
kaliamoorthi 2014/02/11 16:29:16 Done.
+BASE_EXPORT bool ReadFileToString(const FilePath& path,
+ std::string* contents,
+ size_t maxsize);
bartfab (slow) 2014/02/11 12:51:12 Nit: s/maxsize/max_size/ to be more consistent wit
kaliamoorthi 2014/02/11 16:29:16 Done.
+
#if defined(OS_POSIX)
// Read exactly |bytes| bytes from file descriptor |fd|, storing the result
« no previous file with comments | « no previous file | base/file_util.cc » ('j') | base/file_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698