| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
| 6 // filesystem. | 6 // filesystem. |
| 7 | 7 |
| 8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
| 9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Returns true if the contents of the two files given are equal, false | 152 // Returns true if the contents of the two files given are equal, false |
| 153 // otherwise. If either file can't be read, returns false. | 153 // otherwise. If either file can't be read, returns false. |
| 154 bool ContentsEqual(const FilePath& filename1, | 154 bool ContentsEqual(const FilePath& filename1, |
| 155 const FilePath& filename2); | 155 const FilePath& filename2); |
| 156 | 156 |
| 157 // Returns true if the contents of the two text files given are equal, false | 157 // Returns true if the contents of the two text files given are equal, false |
| 158 // otherwise. This routine treats "\r\n" and "\n" as equivalent. | 158 // otherwise. This routine treats "\r\n" and "\n" as equivalent. |
| 159 bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2); | 159 bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2); |
| 160 | 160 |
| 161 // Read the file at |path| into |contents|, returning true on success. | 161 // Read the file at |path| into |contents|, returning true on success. |
| 162 // |contents| may be NULL, in which case this function is useful for its |
| 163 // side effect of priming the disk cache. |
| 162 // Useful for unit tests. | 164 // Useful for unit tests. |
| 163 bool ReadFileToString(const FilePath& path, std::string* contents); | 165 bool ReadFileToString(const FilePath& path, std::string* contents); |
| 164 | 166 |
| 165 #if defined(OS_POSIX) | 167 #if defined(OS_POSIX) |
| 166 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result | 168 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |
| 167 // in |buffer|. This function is protected against EINTR and partial reads. | 169 // in |buffer|. This function is protected against EINTR and partial reads. |
| 168 // Returns true iff |bytes| bytes have been successfuly read from |fd|. | 170 // Returns true iff |bytes| bytes have been successfuly read from |fd|. |
| 169 bool ReadFromFD(int fd, char* buffer, size_t bytes); | 171 bool ReadFromFD(int fd, char* buffer, size_t bytes); |
| 170 #endif // defined(OS_POSIX) | 172 #endif // defined(OS_POSIX) |
| 171 | 173 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 578 |
| 577 #endif // UNIT_TEST | 579 #endif // UNIT_TEST |
| 578 | 580 |
| 579 } // namespace file_util | 581 } // namespace file_util |
| 580 | 582 |
| 581 // Deprecated functions have been moved to this separate header file, | 583 // Deprecated functions have been moved to this separate header file, |
| 582 // which must be included last after all the above definitions. | 584 // which must be included last after all the above definitions. |
| 583 #include "base/file_util_deprecated.h" | 585 #include "base/file_util_deprecated.h" |
| 584 | 586 |
| 585 #endif // BASE_FILE_UTIL_H_ | 587 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |