| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 BASE_EXPORT bool CloseFile(FILE* file); | 321 BASE_EXPORT bool CloseFile(FILE* file); |
| 322 | 322 |
| 323 // Truncates an open file to end at the location of the current file pointer. | 323 // Truncates an open file to end at the location of the current file pointer. |
| 324 // This is a cross-platform analog to Windows' SetEndOfFile() function. | 324 // This is a cross-platform analog to Windows' SetEndOfFile() function. |
| 325 BASE_EXPORT bool TruncateFile(FILE* file); | 325 BASE_EXPORT bool TruncateFile(FILE* file); |
| 326 | 326 |
| 327 // Reads the given number of bytes from the file into the buffer. Returns | 327 // Reads the given number of bytes from the file into the buffer. Returns |
| 328 // the number of read bytes, or -1 on error. | 328 // the number of read bytes, or -1 on error. |
| 329 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int size); | 329 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int size); |
| 330 | 330 |
| 331 // Writes the given buffer into the file, overwriting any data that was |
| 332 // previously there. Returns the number of bytes written, or -1 on error. |
| 333 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, |
| 334 int size); |
| 335 |
| 336 #if defined(OS_POSIX) |
| 337 // Append the data to |fd|. Does not close |fd| when done. |
| 338 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); |
| 339 #endif |
| 340 |
| 331 } // namespace base | 341 } // namespace base |
| 332 | 342 |
| 333 // ----------------------------------------------------------------------------- | 343 // ----------------------------------------------------------------------------- |
| 334 | 344 |
| 335 namespace file_util { | 345 namespace file_util { |
| 336 | 346 |
| 337 // Writes the given buffer into the file, overwriting any data that was | |
| 338 // previously there. Returns the number of bytes written, or -1 on error. | |
| 339 BASE_EXPORT int WriteFile(const base::FilePath& filename, const char* data, | |
| 340 int size); | |
| 341 #if defined(OS_POSIX) | |
| 342 // Append the data to |fd|. Does not close |fd| when done. | |
| 343 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); | |
| 344 #endif | |
| 345 // Append the given buffer into the file. Returns the number of bytes written, | 347 // Append the given buffer into the file. Returns the number of bytes written, |
| 346 // or -1 on error. | 348 // or -1 on error. |
| 347 BASE_EXPORT int AppendToFile(const base::FilePath& filename, | 349 BASE_EXPORT int AppendToFile(const base::FilePath& filename, |
| 348 const char* data, int size); | 350 const char* data, int size); |
| 349 | 351 |
| 350 // Gets the current working directory for the process. | 352 // Gets the current working directory for the process. |
| 351 BASE_EXPORT bool GetCurrentDirectory(base::FilePath* path); | 353 BASE_EXPORT bool GetCurrentDirectory(base::FilePath* path); |
| 352 | 354 |
| 353 // Sets the current working directory for the process. | 355 // Sets the current working directory for the process. |
| 354 BASE_EXPORT bool SetCurrentDirectory(const base::FilePath& path); | 356 BASE_EXPORT bool SetCurrentDirectory(const base::FilePath& path); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // This function simulates Move(), but unlike Move() it works across volumes. | 475 // This function simulates Move(), but unlike Move() it works across volumes. |
| 474 // This function is not transactional. | 476 // This function is not transactional. |
| 475 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 477 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 476 const FilePath& to_path); | 478 const FilePath& to_path); |
| 477 #endif // defined(OS_WIN) | 479 #endif // defined(OS_WIN) |
| 478 | 480 |
| 479 } // namespace internal | 481 } // namespace internal |
| 480 } // namespace base | 482 } // namespace base |
| 481 | 483 |
| 482 #endif // BASE_FILE_UTIL_H_ | 484 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |