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 25 matching lines...) Expand all Loading... | |
36 #include "base/file_descriptor_posix.h" | 36 #include "base/file_descriptor_posix.h" |
37 #include "base/logging.h" | 37 #include "base/logging.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace base { | 40 namespace base { |
41 class Time; | 41 class Time; |
42 } | 42 } |
43 | 43 |
44 namespace file_util { | 44 namespace file_util { |
45 | 45 |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
Evan Martin
2011/09/21 18:15:24
Probably didn't mean for so much whitespace here a
Sam Kerner (Chrome)
2011/09/21 18:57:07
Trybots have been failing to patch changes to this
| |
53 #if defined(OS_POSIX) | |
54 // Test that |path| can only be changed by a specific user and group. | |
55 // Specifically, test that all parts of |path| under and including |base| | |
56 // exist, are owned by a specific user and group, are not writable by all | |
57 // users, and are not symbolic links. This is useful for checking that a | |
58 // config file is administrator-controlled. |base| must contain |path|. | |
59 BASE_EXPORT bool VerifyPathControlledByUser(const FilePath& base, | |
60 const FilePath* path, | |
Evan Martin
2011/09/21 18:15:24
Why is this a pointer? If it being NULL has a mea
Sam Kerner (Chrome)
2011/09/21 18:57:07
Fixed.
| |
61 uid_t owner_uid, | |
62 gid_t group_gid); | |
63 #endif // defined(OS_POSIX) | |
64 | |
65 #if defined(OS_MACOSX) | |
66 // Is |path|writable only by a user with administrator privlages? | |
67 // This function uses Mac OS conventions. It assumes that the superuser | |
68 // has uid 0, and the administrator group is named "admin". Test that | |
69 // |path| and every parent directory (including the root of the | |
70 // filesystem) are owned by the superuser, controlled by the admin | |
71 // group, are not writable by all users, and contain no symbolic links. | |
72 // Will return false if |path| does not exist. | |
73 BASE_EXPORT bool VerifyPathControlledByAdmin(const FilePath& path); | |
74 #endif // defined(OS_MACOSX) | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
46 //----------------------------------------------------------------------------- | 81 //----------------------------------------------------------------------------- |
47 // Functions that operate purely on a path string w/o touching the filesystem: | 82 // Functions that operate purely on a path string w/o touching the filesystem: |
Evan Martin
2011/09/21 18:15:24
It looks like this file might be organized into ca
Sam Kerner (Chrome)
2011/09/21 18:57:07
Put them with functions that touch the filesystem.
| |
48 | 83 |
49 // Returns true if the given path ends with a path separator character. | 84 // Returns true if the given path ends with a path separator character. |
50 BASE_EXPORT bool EndsWithSeparator(const FilePath& path); | 85 BASE_EXPORT bool EndsWithSeparator(const FilePath& path); |
51 | 86 |
52 // Makes sure that |path| ends with a separator IFF path is a directory that | 87 // Makes sure that |path| ends with a separator IFF path is a directory that |
53 // exists. Returns true if |path| is an existing directory, false otherwise. | 88 // exists. Returns true if |path| is an existing directory, false otherwise. |
54 BASE_EXPORT bool EnsureEndsWithSeparator(FilePath* path); | 89 BASE_EXPORT bool EnsureEndsWithSeparator(FilePath* path); |
55 | 90 |
56 // Convert provided relative path into an absolute path. Returns false on | 91 // Convert provided relative path into an absolute path. Returns false on |
57 // error. On POSIX, this function fails if the path does not exist. | 92 // error. On POSIX, this function fails if the path does not exist. |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 633 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
599 #endif | 634 #endif |
600 | 635 |
601 } // namespace file_util | 636 } // namespace file_util |
602 | 637 |
603 // Deprecated functions have been moved to this separate header file, | 638 // Deprecated functions have been moved to this separate header file, |
604 // which must be included last after all the above definitions. | 639 // which must be included last after all the above definitions. |
605 #include "base/file_util_deprecated.h" | 640 #include "base/file_util_deprecated.h" |
606 | 641 |
607 #endif // BASE_FILE_UTIL_H_ | 642 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |