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 number of files matching the current path that were | 57 // Returns the number of files matching the current path that were |
71 // created on or after the given |file_time|. Doesn't count ".." or ".". | 58 // created on or after the given |file_time|. Doesn't count ".." or ".". |
72 // | 59 // |
73 // Note for POSIX environments: a file created before |file_time| | 60 // Note for POSIX environments: a file created before |file_time| |
74 // can be mis-detected as a newer file due to low precision of | 61 // can be mis-detected as a newer file due to low precision of |
75 // timestmap of file creation time. If you need to avoid such | 62 // timestmap of file creation time. If you need to avoid such |
76 // mis-detection perfectly, you should wait one second before | 63 // mis-detection perfectly, you should wait one second before |
77 // obtaining |file_time|. | 64 // obtaining |file_time|. |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 569 |
583 // Attempts determine the FileSystemType for |path|. | 570 // Attempts determine the FileSystemType for |path|. |
584 // Returns false if |path| doesn't exist. | 571 // Returns false if |path| doesn't exist. |
585 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, | 572 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, |
586 FileSystemType* type); | 573 FileSystemType* type); |
587 #endif | 574 #endif |
588 | 575 |
589 } // namespace file_util | 576 } // namespace file_util |
590 | 577 |
591 #endif // BASE_FILE_UTIL_H_ | 578 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |