 Chromium Code Reviews
 Chromium Code Reviews Issue 157593005:
  Added new ReadFileToString API with a max_size argument  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 157593005:
  Added new ReadFileToString API with a max_size argument  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: base/file_util.h | 
| diff --git a/base/file_util.h b/base/file_util.h | 
| index f8418318a6a7ecd92255e6d708624b7f1ae6bcf7..483ef6600ec1379f81ab83178dabaf960c89566a 100644 | 
| --- a/base/file_util.h | 
| +++ b/base/file_util.h | 
| @@ -133,10 +133,24 @@ BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, | 
| // Read the file at |path| into |contents|, returning true on success. | 
| // This function fails if the |path| contains path traversal components ('..'). | 
| // |contents| may be NULL, in which case this function is useful for its | 
| -// side effect of priming the disk cache. | 
| -// Useful for unit tests. | 
| +// side effect of priming the disk cache, which is useful for unit tests. | 
| 
bartfab (slow)
2014/02/18 14:56:51
Nit: The sentence now says that the function is "u
 | 
| +// The function replaces rather than append to |contents|, further |contents| | 
| 
bartfab (slow)
2014/02/18 14:56:51
Nit 1: s/append/appending/
Nit 2: Document the beh
 | 
| +// could be cleared on error. | 
| 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 ('..'). | 
| +// |contents| may be NULL, in which case this function is useful for its | 
| 
bartfab (slow)
2014/02/18 14:56:51
Nit: The sentence now says that the function is "u
 | 
| +// side effect of priming the disk cache, which is useful for unit tests. | 
| +// The function replaces rather than append to |contents|, further |contents| | 
| 
bartfab (slow)
2014/02/18 14:56:51
Nit 1: s/append/appending/
Nit 2: Document the beh
 | 
| +// could be cleared on error. | 
| +BASE_EXPORT bool ReadFileToString(const FilePath& path, | 
| + std::string* contents, | 
| + size_t max_size); | 
| + | 
| #if defined(OS_POSIX) | 
| // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |