Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, | 130 BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, |
| 131 const FilePath& filename2); | 131 const FilePath& filename2); |
| 132 | 132 |
| 133 // Read the file at |path| into |contents|, returning true on success. | 133 // Read the file at |path| into |contents|, returning true on success. |
| 134 // This function fails if the |path| contains path traversal components ('..'). | 134 // This function fails if the |path| contains path traversal components ('..'). |
| 135 // |contents| may be NULL, in which case this function is useful for its | 135 // |contents| may be NULL, in which case this function is useful for its |
| 136 // side effect of priming the disk cache. | 136 // side effect of priming the disk cache. |
| 137 // Useful for unit tests. | 137 // Useful for unit tests. |
| 138 BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents); | 138 BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents); |
| 139 | 139 |
| 140 // Read the file at |path| into |contents|, returning true on success. | |
| 141 // This function has an additional check on the maximum size of the file. | |
| 142 // When the file size is greater than |maxsize|, the function returns false | |
| 143 // 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.
| |
| 144 BASE_EXPORT bool ReadFileToString(const FilePath& path, | |
| 145 std::string* contents, | |
| 146 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.
| |
| 147 | |
| 140 #if defined(OS_POSIX) | 148 #if defined(OS_POSIX) |
| 141 | 149 |
| 142 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result | 150 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |
| 143 // in |buffer|. This function is protected against EINTR and partial reads. | 151 // in |buffer|. This function is protected against EINTR and partial reads. |
| 144 // Returns true iff |bytes| bytes have been successfully read from |fd|. | 152 // Returns true iff |bytes| bytes have been successfully read from |fd|. |
| 145 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); | 153 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); |
| 146 | 154 |
| 147 // Creates a symbolic link at |symlink| pointing to |target|. Returns | 155 // Creates a symbolic link at |symlink| pointing to |target|. Returns |
| 148 // false on failure. | 156 // false on failure. |
| 149 BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, | 157 BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 // This function simulates Move(), but unlike Move() it works across volumes. | 464 // This function simulates Move(), but unlike Move() it works across volumes. |
| 457 // This function is not transactional. | 465 // This function is not transactional. |
| 458 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 466 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 459 const FilePath& to_path); | 467 const FilePath& to_path); |
| 460 #endif // defined(OS_WIN) | 468 #endif // defined(OS_WIN) |
| 461 | 469 |
| 462 } // namespace internal | 470 } // namespace internal |
| 463 } // namespace base | 471 } // namespace base |
| 464 | 472 |
| 465 #endif // BASE_FILE_UTIL_H_ | 473 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |