| 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_FILES_FILE_UTIL_H_ | 8 #ifndef BASE_FILES_FILE_UTIL_H_ |
| 9 #define BASE_FILES_FILE_UTIL_H_ | 9 #define BASE_FILES_FILE_UTIL_H_ |
| 10 | 10 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // Truncates an open file to end at the location of the current file pointer. | 315 // Truncates an open file to end at the location of the current file pointer. |
| 316 // This is a cross-platform analog to Windows' SetEndOfFile() function. | 316 // This is a cross-platform analog to Windows' SetEndOfFile() function. |
| 317 BASE_EXPORT bool TruncateFile(FILE* file); | 317 BASE_EXPORT bool TruncateFile(FILE* file); |
| 318 | 318 |
| 319 // Reads at most the given number of bytes from the file into the buffer. | 319 // Reads at most the given number of bytes from the file into the buffer. |
| 320 // Returns the number of read bytes, or -1 on error. | 320 // Returns the number of read bytes, or -1 on error. |
| 321 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); | 321 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); |
| 322 | 322 |
| 323 // Writes the given buffer into the file, overwriting any data that was | 323 // Writes the given buffer into the file, overwriting any data that was |
| 324 // previously there. Returns the number of bytes written, or -1 on error. | 324 // previously there. Returns the number of bytes written, or -1 on error. |
| 325 // The file will be created with a default mode (POSIX) or security |
| 326 // descriptor (Windows). To specify a mode on POSIX, use |WriteFileWithMode|. |
| 325 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, | 327 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, |
| 326 int size); | 328 int size); |
| 327 | 329 |
| 328 #if defined(OS_POSIX) | 330 #if defined(OS_POSIX) |
| 329 // Appends |data| to |fd|. Does not close |fd| when done. Returns true iff | 331 // Appends |data| to |fd|. Does not close |fd| when done. Returns true iff |
| 330 // |size| bytes of |data| were written to |fd|. | 332 // |size| bytes of |data| were written to |fd|. |
| 331 BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size); | 333 BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size); |
| 334 |
| 335 // Writes the given buffer into the file, overwriting any data that was |
| 336 // previously there. Returns true iff |size| bytes of |data| were written to |
| 337 // |filename|. The file is created with the given |mode|. |
| 338 BASE_EXPORT bool WriteFileWithMode(const FilePath& filename, const char* data, |
| 339 int size, mode_t mode); |
| 332 #endif | 340 #endif |
| 333 | 341 |
| 334 // Appends |data| to |filename|. Returns true iff |size| bytes of |data| were | 342 // Appends |data| to |filename|. Returns true iff |size| bytes of |data| were |
| 335 // written to |filename|. | 343 // written to |filename|. |
| 336 BASE_EXPORT bool AppendToFile(const FilePath& filename, | 344 BASE_EXPORT bool AppendToFile(const FilePath& filename, |
| 337 const char* data, | 345 const char* data, |
| 338 int size); | 346 int size); |
| 339 | 347 |
| 340 // Gets the current working directory for the process. | 348 // Gets the current working directory for the process. |
| 341 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); | 349 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // This function simulates Move(), but unlike Move() it works across volumes. | 440 // This function simulates Move(), but unlike Move() it works across volumes. |
| 433 // This function is not transactional. | 441 // This function is not transactional. |
| 434 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 442 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 435 const FilePath& to_path); | 443 const FilePath& to_path); |
| 436 #endif // defined(OS_WIN) | 444 #endif // defined(OS_WIN) |
| 437 | 445 |
| 438 } // namespace internal | 446 } // namespace internal |
| 439 } // namespace base | 447 } // namespace base |
| 440 | 448 |
| 441 #endif // BASE_FILES_FILE_UTIL_H_ | 449 #endif // BASE_FILES_FILE_UTIL_H_ |
| OLD | NEW |