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 21 matching lines...) Expand all Loading... |
32 #include "base/string16.h" | 32 #include "base/string16.h" |
33 | 33 |
34 #if defined(OS_POSIX) | 34 #if defined(OS_POSIX) |
35 #include "base/file_descriptor_posix.h" | 35 #include "base/file_descriptor_posix.h" |
36 #include "base/logging.h" | 36 #include "base/logging.h" |
37 #include "base/posix/eintr_wrapper.h" | 37 #include "base/posix/eintr_wrapper.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace base { | 40 namespace base { |
41 class Time; | 41 class Time; |
42 } | 42 |
| 43 // Returns an absolute version of a relative path. Returns an empty path on |
| 44 // error. On POSIX, this function fails if the path does not exist. This |
| 45 // function can result in I/O so it can be slow. |
| 46 BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); |
| 47 |
| 48 } // namespace base |
43 | 49 |
44 namespace file_util { | 50 namespace file_util { |
45 | 51 |
46 extern bool g_bug108724_debug; | 52 extern bool g_bug108724_debug; |
47 | 53 |
48 //----------------------------------------------------------------------------- | 54 //----------------------------------------------------------------------------- |
49 // Functions that operate purely on a path string w/o touching the filesystem: | |
50 | |
51 // Returns true if the given path ends with a path separator character. | |
52 BASE_EXPORT bool EndsWithSeparator(const base::FilePath& path); | |
53 | |
54 // Makes sure that |path| ends with a separator IFF path is a directory that | |
55 // exists. Returns true if |path| is an existing directory, false otherwise. | |
56 BASE_EXPORT bool EnsureEndsWithSeparator(base::FilePath* path); | |
57 | |
58 // Convert provided relative path into an absolute path. Returns false on | |
59 // error. On POSIX, this function fails if the path does not exist. | |
60 BASE_EXPORT bool AbsolutePath(base::FilePath* path); | |
61 | |
62 // Returns true if |parent| contains |child|. Both paths are converted to | |
63 // absolute paths before doing the comparison. | |
64 BASE_EXPORT bool ContainsPath(const base::FilePath& parent, | |
65 const base::FilePath& child); | |
66 | |
67 //----------------------------------------------------------------------------- | |
68 // Functions that involve filesystem access or modification: | 55 // Functions that involve filesystem access or modification: |
69 | 56 |
70 // Returns the total number of bytes used by all the files under |root_path|. | 57 // Returns the total number of bytes used by all the files under |root_path|. |
71 // If the path does not exist the function returns 0. | 58 // If the path does not exist the function returns 0. |
72 // | 59 // |
73 // This function is implemented using the FileEnumerator class so it is not | 60 // This function is implemented using the FileEnumerator class so it is not |
74 // particularly speedy in any platform. | 61 // particularly speedy in any platform. |
75 BASE_EXPORT int64 ComputeDirectorySize(const base::FilePath& root_path); | 62 BASE_EXPORT int64 ComputeDirectorySize(const base::FilePath& root_path); |
76 | 63 |
77 // Deletes the given path, whether it's a file or a directory. | 64 // Deletes the given path, whether it's a file or a directory. |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 551 |
565 // Attempts determine the FileSystemType for |path|. | 552 // Attempts determine the FileSystemType for |path|. |
566 // Returns false if |path| doesn't exist. | 553 // Returns false if |path| doesn't exist. |
567 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, | 554 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, |
568 FileSystemType* type); | 555 FileSystemType* type); |
569 #endif | 556 #endif |
570 | 557 |
571 } // namespace file_util | 558 } // namespace file_util |
572 | 559 |
573 #endif // BASE_FILE_UTIL_H_ | 560 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |