| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 BASE_EXPORT bool IsLink(const FilePath& file_path); | 292 BASE_EXPORT bool IsLink(const FilePath& file_path); |
| 293 | 293 |
| 294 // Returns information about the given file path. | 294 // Returns information about the given file path. |
| 295 BASE_EXPORT bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* info); | 295 BASE_EXPORT bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* info); |
| 296 | 296 |
| 297 // Sets the time of the last access and the time of the last modification. | 297 // Sets the time of the last access and the time of the last modification. |
| 298 BASE_EXPORT bool TouchFile(const FilePath& path, | 298 BASE_EXPORT bool TouchFile(const FilePath& path, |
| 299 const Time& last_accessed, | 299 const Time& last_accessed, |
| 300 const Time& last_modified); | 300 const Time& last_modified); |
| 301 | 301 |
| 302 } // namespace base | |
| 303 | |
| 304 // ----------------------------------------------------------------------------- | |
| 305 | |
| 306 namespace file_util { | |
| 307 | |
| 308 #if defined(OS_POSIX) | |
| 309 // Store inode number of |path| in |inode|. Return true on success. | |
| 310 BASE_EXPORT bool GetInode(const base::FilePath& path, ino_t* inode); | |
| 311 #endif | |
| 312 | |
| 313 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. | 302 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. |
| 314 BASE_EXPORT FILE* OpenFile(const base::FilePath& filename, const char* mode); | 303 BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode); |
| 315 | 304 |
| 316 // Closes file opened by OpenFile. Returns true on success. | 305 // Closes file opened by OpenFile. Returns true on success. |
| 317 BASE_EXPORT bool CloseFile(FILE* file); | 306 BASE_EXPORT bool CloseFile(FILE* file); |
| 318 | 307 |
| 319 // 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. |
| 320 // This is a cross-platform analog to Windows' SetEndOfFile() function. | 309 // This is a cross-platform analog to Windows' SetEndOfFile() function. |
| 321 BASE_EXPORT bool TruncateFile(FILE* file); | 310 BASE_EXPORT bool TruncateFile(FILE* file); |
| 322 | 311 |
| 323 // Reads the given number of bytes from the file into the buffer. Returns | 312 // Reads the given number of bytes from the file into the buffer. Returns |
| 324 // the number of read bytes, or -1 on error. | 313 // the number of read bytes, or -1 on error. |
| 325 BASE_EXPORT int ReadFile(const base::FilePath& filename, char* data, int size); | 314 BASE_EXPORT int ReadFile(const base::FilePath& filename, char* data, int size); |
| 326 | 315 |
| 316 } // namespace base |
| 317 |
| 318 // ----------------------------------------------------------------------------- |
| 319 |
| 320 namespace file_util { |
| 321 |
| 327 // Writes the given buffer into the file, overwriting any data that was | 322 // Writes the given buffer into the file, overwriting any data that was |
| 328 // previously there. Returns the number of bytes written, or -1 on error. | 323 // previously there. Returns the number of bytes written, or -1 on error. |
| 329 BASE_EXPORT int WriteFile(const base::FilePath& filename, const char* data, | 324 BASE_EXPORT int WriteFile(const base::FilePath& filename, const char* data, |
| 330 int size); | 325 int size); |
| 331 #if defined(OS_POSIX) | 326 #if defined(OS_POSIX) |
| 332 // Append the data to |fd|. Does not close |fd| when done. | 327 // Append the data to |fd|. Does not close |fd| when done. |
| 333 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); | 328 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); |
| 334 #endif | 329 #endif |
| 335 // Append the given buffer into the file. Returns the number of bytes written, | 330 // Append the given buffer into the file. Returns the number of bytes written, |
| 336 // or -1 on error. | 331 // or -1 on error. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // This function simulates Move(), but unlike Move() it works across volumes. | 456 // This function simulates Move(), but unlike Move() it works across volumes. |
| 462 // This function is not transactional. | 457 // This function is not transactional. |
| 463 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 458 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 464 const FilePath& to_path); | 459 const FilePath& to_path); |
| 465 #endif // defined(OS_WIN) | 460 #endif // defined(OS_WIN) |
| 466 | 461 |
| 467 } // namespace internal | 462 } // namespace internal |
| 468 } // namespace base | 463 } // namespace base |
| 469 | 464 |
| 470 #endif // BASE_FILE_UTIL_H_ | 465 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |