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

Side by Side Diff: base/file_util.h

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/proc_maps_linux.cc ('k') | base/file_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Returns true if the contents of the two files given are equal, false 125 // Returns true if the contents of the two files given are equal, false
126 // otherwise. If either file can't be read, returns false. 126 // otherwise. If either file can't be read, returns false.
127 BASE_EXPORT bool ContentsEqual(const FilePath& filename1, 127 BASE_EXPORT bool ContentsEqual(const FilePath& filename1,
128 const FilePath& filename2); 128 const FilePath& filename2);
129 129
130 // Returns true if the contents of the two text files given are equal, false 130 // Returns true if the contents of the two text files given are equal, false
131 // otherwise. This routine treats "\r\n" and "\n" as equivalent. 131 // otherwise. This routine treats "\r\n" and "\n" as equivalent.
132 BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, 132 BASE_EXPORT bool TextContentsEqual(const FilePath& filename1,
133 const FilePath& filename2); 133 const FilePath& filename2);
134 134
135 // Read the file at |path| into |contents|, returning true on success.
136 // This function fails if the |path| contains path traversal components ('..').
137 // |contents| may be NULL, in which case this function is useful for its
138 // side effect of priming the disk cache.
139 // Useful for unit tests.
140 BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents);
141
135 } // namespace base 142 } // namespace base
136 143
137 // ----------------------------------------------------------------------------- 144 // -----------------------------------------------------------------------------
138 145
139 namespace file_util { 146 namespace file_util {
140 147
141 // Read the file at |path| into |contents|, returning true on success.
142 // This function fails if the |path| contains path traversal components ('..').
143 // |contents| may be NULL, in which case this function is useful for its
144 // side effect of priming the disk cache.
145 // Useful for unit tests.
146 BASE_EXPORT bool ReadFileToString(const base::FilePath& path,
147 std::string* contents);
148
149 #if defined(OS_POSIX) 148 #if defined(OS_POSIX)
150 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result 149 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result
151 // in |buffer|. This function is protected against EINTR and partial reads. 150 // in |buffer|. This function is protected against EINTR and partial reads.
152 // Returns true iff |bytes| bytes have been successfully read from |fd|. 151 // Returns true iff |bytes| bytes have been successfully read from |fd|.
153 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); 152 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes);
154 153
155 // Creates a symbolic link at |symlink| pointing to |target|. Returns 154 // Creates a symbolic link at |symlink| pointing to |target|. Returns
156 // false on failure. 155 // false on failure.
157 BASE_EXPORT bool CreateSymbolicLink(const base::FilePath& target, 156 BASE_EXPORT bool CreateSymbolicLink(const base::FilePath& target,
158 const base::FilePath& symlink); 157 const base::FilePath& symlink);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // This function simulates Move(), but unlike Move() it works across volumes. 454 // This function simulates Move(), but unlike Move() it works across volumes.
456 // This function is not transactional. 455 // This function is not transactional.
457 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, 456 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
458 const FilePath& to_path); 457 const FilePath& to_path);
459 #endif // defined(OS_WIN) 458 #endif // defined(OS_WIN)
460 459
461 } // namespace internal 460 } // namespace internal
462 } // namespace base 461 } // namespace base
463 462
464 #endif // BASE_FILE_UTIL_H_ 463 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/debug/proc_maps_linux.cc ('k') | base/file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698