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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. | 302 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. |
303 BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode); | 303 BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode); |
304 | 304 |
305 // Closes file opened by OpenFile. Returns true on success. | 305 // Closes file opened by OpenFile. Returns true on success. |
306 BASE_EXPORT bool CloseFile(FILE* file); | 306 BASE_EXPORT bool CloseFile(FILE* file); |
307 | 307 |
308 // Truncates an open file to end at the location of the current file pointer. | 308 // Truncates an open file to end at the location of the current file pointer. |
309 // This is a cross-platform analog to Windows' SetEndOfFile() function. | 309 // This is a cross-platform analog to Windows' SetEndOfFile() function. |
310 BASE_EXPORT bool TruncateFile(FILE* file); | 310 BASE_EXPORT bool TruncateFile(FILE* file); |
311 | 311 |
312 // Reads the given number of bytes from the file into the buffer. Returns | 312 // Reads at most the given number of bytes from the file into the buffer. |
313 // the number of read bytes, or -1 on error. | 313 // Returns the number of read bytes, or -1 on error. |
314 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int size); | 314 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); |
315 | 315 |
316 // Writes the given buffer into the file, overwriting any data that was | 316 // Writes the given buffer into the file, overwriting any data that was |
317 // previously there. Returns the number of bytes written, or -1 on error. | 317 // previously there. Returns the number of bytes written, or -1 on error. |
318 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, | 318 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, |
319 int size); | 319 int size); |
320 | 320 |
321 #if defined(OS_POSIX) | 321 #if defined(OS_POSIX) |
322 // Append the data to |fd|. Does not close |fd| when done. | 322 // Append the data to |fd|. Does not close |fd| when done. |
323 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); | 323 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); |
324 #endif | 324 #endif |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // This function simulates Move(), but unlike Move() it works across volumes. | 443 // This function simulates Move(), but unlike Move() it works across volumes. |
444 // This function is not transactional. | 444 // This function is not transactional. |
445 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 445 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
446 const FilePath& to_path); | 446 const FilePath& to_path); |
447 #endif // defined(OS_WIN) | 447 #endif // defined(OS_WIN) |
448 | 448 |
449 } // namespace internal | 449 } // namespace internal |
450 } // namespace base | 450 } // namespace base |
451 | 451 |
452 #endif // BASE_FILE_UTIL_H_ | 452 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |