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 | |
Andrew T Wilson (Slow)
2014/02/10 14:29:46
nit: put a period at the end of the sentence. Also
kaliamoorthi
2014/02/11 10:10:45
Done.
| |
142 BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents, | |
143 size_t maxsize); | |
144 | |
140 #if defined(OS_POSIX) | 145 #if defined(OS_POSIX) |
141 | 146 |
142 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result | 147 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |
143 // in |buffer|. This function is protected against EINTR and partial reads. | 148 // in |buffer|. This function is protected against EINTR and partial reads. |
144 // Returns true iff |bytes| bytes have been successfully read from |fd|. | 149 // Returns true iff |bytes| bytes have been successfully read from |fd|. |
145 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); | 150 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); |
146 | 151 |
147 // Creates a symbolic link at |symlink| pointing to |target|. Returns | 152 // Creates a symbolic link at |symlink| pointing to |target|. Returns |
148 // false on failure. | 153 // false on failure. |
149 BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, | 154 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. | 461 // This function simulates Move(), but unlike Move() it works across volumes. |
457 // This function is not transactional. | 462 // This function is not transactional. |
458 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 463 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
459 const FilePath& to_path); | 464 const FilePath& to_path); |
460 #endif // defined(OS_WIN) | 465 #endif // defined(OS_WIN) |
461 | 466 |
462 } // namespace internal | 467 } // namespace internal |
463 } // namespace base | 468 } // namespace base |
464 | 469 |
465 #endif // BASE_FILE_UTIL_H_ | 470 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |