| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, | 325 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, |
| 326 int size); | 326 int size); |
| 327 | 327 |
| 328 #if defined(OS_POSIX) | 328 #if defined(OS_POSIX) |
| 329 // Append the data to |fd|. Does not close |fd| when done. | 329 // Appends |data| to |fd|. Does not close |fd| when done. Returns true iff |
| 330 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); | 330 // |size| bytes of |data| were written to |fd|. |
| 331 BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size); |
| 331 #endif | 332 #endif |
| 332 | 333 |
| 333 // Append the given buffer into the file. Returns the number of bytes written, | 334 // Appends |data| to |filename|. Returns true iff |size| bytes of |data| were |
| 334 // or -1 on error. | 335 // written to |filename|. |
| 335 BASE_EXPORT int AppendToFile(const FilePath& filename, | 336 BASE_EXPORT bool AppendToFile(const FilePath& filename, |
| 336 const char* data, int size); | 337 const char* data, |
| 338 int size); |
| 337 | 339 |
| 338 // Gets the current working directory for the process. | 340 // Gets the current working directory for the process. |
| 339 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); | 341 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); |
| 340 | 342 |
| 341 // Sets the current working directory for the process. | 343 // Sets the current working directory for the process. |
| 342 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); | 344 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); |
| 343 | 345 |
| 344 // Attempts to find a number that can be appended to the |path| to make it | 346 // Attempts to find a number that can be appended to the |path| to make it |
| 345 // unique. If |path| does not exist, 0 is returned. If it fails to find such | 347 // unique. If |path| does not exist, 0 is returned. If it fails to find such |
| 346 // a number, -1 is returned. If |suffix| is not empty, also checks the | 348 // a number, -1 is returned. If |suffix| is not empty, also checks the |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // This function simulates Move(), but unlike Move() it works across volumes. | 432 // This function simulates Move(), but unlike Move() it works across volumes. |
| 431 // This function is not transactional. | 433 // This function is not transactional. |
| 432 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 434 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 433 const FilePath& to_path); | 435 const FilePath& to_path); |
| 434 #endif // defined(OS_WIN) | 436 #endif // defined(OS_WIN) |
| 435 | 437 |
| 436 } // namespace internal | 438 } // namespace internal |
| 437 } // namespace base | 439 } // namespace base |
| 438 | 440 |
| 439 #endif // BASE_FILES_FILE_UTIL_H_ | 441 #endif // BASE_FILES_FILE_UTIL_H_ |
| OLD | NEW |