| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 10 #pragma once |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 // Returns the file size. Returns true on success. | 292 // Returns the file size. Returns true on success. |
| 293 bool GetFileSize(const FilePath& file_path, int64* file_size); | 293 bool GetFileSize(const FilePath& file_path, int64* file_size); |
| 294 | 294 |
| 295 // Returns true if the given path's base name is ".". | 295 // Returns true if the given path's base name is ".". |
| 296 bool IsDot(const FilePath& path); | 296 bool IsDot(const FilePath& path); |
| 297 | 297 |
| 298 // Returns true if the given path's base name is "..". | 298 // Returns true if the given path's base name is "..". |
| 299 bool IsDotDot(const FilePath& path); | 299 bool IsDotDot(const FilePath& path); |
| 300 | 300 |
| 301 #if defined(OS_MACOSX) |
| 302 // Returns true if the given path is in the trash. |
| 303 bool IsInTrash(const FilePath& path); |
| 304 |
| 305 // Moves the file to the trash. |
| 306 // If |new_path| is not NULL it will contain the new location. |
| 307 bool MoveToTrash(const FilePath& path, FilePath* new_path); |
| 308 #endif // OS_MACOSX |
| 309 |
| 310 // Are file path a and file path b referring to the same file object. |
| 311 // Does not compare paths, but resolves them and compares the resolved values. |
| 312 bool AreReferringToSameObject(const FilePath& a, const FilePath& b); |
| 313 |
| 301 // Sets |real_path| to |path| with symbolic links and junctions expanded. | 314 // Sets |real_path| to |path| with symbolic links and junctions expanded. |
| 302 // On windows, make sure the path starts with a lettered drive. | 315 // On windows, make sure the path starts with a lettered drive. |
| 303 // |path| must reference a file. Function will fail if |path| points to | 316 // |path| must reference a file. Function will fail if |path| points to |
| 304 // a directory or to a nonexistent path. On windows, this function will | 317 // a directory or to a nonexistent path. On windows, this function will |
| 305 // fail if |path| is a junction or symlink that points to an empty file, | 318 // fail if |path| is a junction or symlink that points to an empty file, |
| 306 // or if |real_path| would be longer than MAX_PATH characters. | 319 // or if |real_path| would be longer than MAX_PATH characters. |
| 307 bool NormalizeFilePath(const FilePath& path, FilePath* real_path); | 320 bool NormalizeFilePath(const FilePath& path, FilePath* real_path); |
| 308 | 321 |
| 309 #if defined(OS_WIN) | 322 #if defined(OS_WIN) |
| 310 // Given an existing file in |path|, it returns in |real_path| the path | 323 // Given an existing file in |path|, it returns in |real_path| the path |
| (...skipping 10 matching lines...) Expand all Loading... |
| 321 bool TouchFile(const FilePath& path, | 334 bool TouchFile(const FilePath& path, |
| 322 const base::Time& last_accessed, | 335 const base::Time& last_accessed, |
| 323 const base::Time& last_modified); | 336 const base::Time& last_modified); |
| 324 | 337 |
| 325 // Set the time of the last modification. Useful for unit tests. | 338 // Set the time of the last modification. Useful for unit tests. |
| 326 bool SetLastModifiedTime(const FilePath& path, | 339 bool SetLastModifiedTime(const FilePath& path, |
| 327 const base::Time& last_modified); | 340 const base::Time& last_modified); |
| 328 | 341 |
| 329 #if defined(OS_POSIX) | 342 #if defined(OS_POSIX) |
| 330 // Store inode number of |path| in |inode|. Return true on success. | 343 // Store inode number of |path| in |inode|. Return true on success. |
| 331 bool GetInode(const FilePath& path, ino_t* inode); | 344 bool GetInodeAndDevice(const FilePath& path, ino_t* inode, dev_t* dev); |
| 332 #endif | 345 #endif |
| 333 | 346 |
| 334 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. | 347 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. |
| 335 FILE* OpenFile(const FilePath& filename, const char* mode); | 348 FILE* OpenFile(const FilePath& filename, const char* mode); |
| 336 | 349 |
| 337 // Closes file opened by OpenFile. Returns true on success. | 350 // Closes file opened by OpenFile. Returns true on success. |
| 338 bool CloseFile(FILE* file); | 351 bool CloseFile(FILE* file); |
| 339 | 352 |
| 340 // Truncates an open file to end at the location of the current file pointer. | 353 // Truncates an open file to end at the location of the current file pointer. |
| 341 // This is a cross-platform analog to Windows' SetEndOfFile() function. | 354 // This is a cross-platform analog to Windows' SetEndOfFile() function. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 647 bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
| 635 #endif | 648 #endif |
| 636 | 649 |
| 637 } // namespace file_util | 650 } // namespace file_util |
| 638 | 651 |
| 639 // Deprecated functions have been moved to this separate header file, | 652 // Deprecated functions have been moved to this separate header file, |
| 640 // which must be included last after all the above definitions. | 653 // which must be included last after all the above definitions. |
| 641 #include "base/file_util_deprecated.h" | 654 #include "base/file_util_deprecated.h" |
| 642 | 655 |
| 643 #endif // BASE_FILE_UTIL_H_ | 656 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |