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 #pragma once | 10 #pragma once |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); | 189 BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); |
190 | 190 |
191 // Creates a symbolic link at |symlink| pointing to |target|. Returns | 191 // Creates a symbolic link at |symlink| pointing to |target|. Returns |
192 // false on failure. | 192 // false on failure. |
193 BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, | 193 BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, |
194 const FilePath& symlink); | 194 const FilePath& symlink); |
195 | 195 |
196 // Reads the given |symlink| and returns where it points to in |target|. | 196 // Reads the given |symlink| and returns where it points to in |target|. |
197 // Returns false upon failure. | 197 // Returns false upon failure. |
198 BASE_EXPORT bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); | 198 BASE_EXPORT bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); |
199 | |
200 // Bits ans masks of the file permission. | |
201 enum FilePermissionBits { | |
202 FILE_PERMISSION_MASK = 00777, | |
203 FILE_PERMISSION_USER_MASK = 00700, | |
204 FILE_PERMISSION_GROUP_MASK = 00070, | |
205 FILE_PERMISSION_OTHERS_MASK = 00007, | |
satorux1
2012/07/04 16:10:41
Not sure if thees masks are needed. maybe remove?
yoshiki
2012/07/09 23:44:11
These are used at file_util_unittest.cc. Keeping.
| |
206 | |
207 FILE_PERMISSION_READ_BY_USER = 00400, | |
satorux1
2012/07/04 16:10:41
Use sys/stat.h constants?
FILE_PERMISSION_READ_BY_
yoshiki
2012/07/09 23:44:11
Done.
| |
208 FILE_PERMISSION_WRITE_BY_USER = 00200, | |
209 FILE_PERMISSION_EXECUTE_BY_USER = 00100, | |
210 FILE_PERMISSION_READ_BY_GROUP = 00040, | |
211 FILE_PERMISSION_WRITE_BY_GROUP = 00020, | |
212 FILE_PERMISSION_EXECUTE_BY_GROUP = 00010, | |
213 FILE_PERMISSION_READ_BY_OTHERS = 00004, | |
214 FILE_PERMISSION_WRITE_BY_OTHERS = 00002, | |
215 FILE_PERMISSION_EXECUTE_BY_OTHERS = 00001, | |
216 }; | |
217 | |
218 // Reads the permission of the given |path|, storing the file permission | |
219 // bits in |mode|. If |path| is symbolic link, |mode| is the permission of | |
220 // a file which the symlink refers to. | |
221 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, | |
222 int* mode); | |
223 // Sets the permission of the given |path|. | |
224 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, | |
225 int mode); | |
226 // Changes the permission of the given |path|. | |
227 BASE_EXPORT bool ChangePosixFilePermissions(const FilePath& path, | |
228 int mode_bits_to_set, | |
229 int mode_bits_to_clear); | |
satorux1
2012/07/04 16:10:41
This function seems to be unnecessary as public AP
yoshiki
2012/07/09 23:44:11
Done.
| |
199 #endif // defined(OS_POSIX) | 230 #endif // defined(OS_POSIX) |
200 | 231 |
201 #if defined(OS_WIN) | 232 #if defined(OS_WIN) |
202 enum ShortcutOptions { | 233 enum ShortcutOptions { |
203 SHORTCUT_NO_OPTIONS = 0, | 234 SHORTCUT_NO_OPTIONS = 0, |
204 // Set DualMode property for Windows 8 Metro-enabled shortcuts. | 235 // Set DualMode property for Windows 8 Metro-enabled shortcuts. |
205 SHORTCUT_DUAL_MODE = 1 << 0, | 236 SHORTCUT_DUAL_MODE = 1 << 0, |
206 // Create a new shortcut (overwriting if necessary). If not specified, only | 237 // Create a new shortcut (overwriting if necessary). If not specified, only |
207 // non-null properties on an existing shortcut will be modified. | 238 // non-null properties on an existing shortcut will be modified. |
208 SHORTCUT_CREATE_ALWAYS = 1 << 1, | 239 SHORTCUT_CREATE_ALWAYS = 1 << 1, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 }; | 667 }; |
637 | 668 |
638 // Attempts determine the FileSystemType for |path|. | 669 // Attempts determine the FileSystemType for |path|. |
639 // Returns false if |path| doesn't exist. | 670 // Returns false if |path| doesn't exist. |
640 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 671 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
641 #endif | 672 #endif |
642 | 673 |
643 } // namespace file_util | 674 } // namespace file_util |
644 | 675 |
645 #endif // BASE_FILE_UTIL_H_ | 676 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |