Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: base/file_util.h

Issue 10756020: Add the methods to change and get a posix file permission to file_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | base/file_util_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 BASE_EXPORT int64 ComputeFilesSize(const FilePath& directory, 94 BASE_EXPORT int64 ComputeFilesSize(const FilePath& directory,
95 const FilePath::StringType& pattern); 95 const FilePath::StringType& pattern);
96 96
97 // Deletes the given path, whether it's a file or a directory. 97 // Deletes the given path, whether it's a file or a directory.
98 // If it's a directory, it's perfectly happy to delete all of the 98 // If it's a directory, it's perfectly happy to delete all of the
99 // directory's contents. Passing true to recursive deletes 99 // directory's contents. Passing true to recursive deletes
100 // subdirectories and their contents as well. 100 // subdirectories and their contents as well.
101 // Returns true if successful, false otherwise. 101 // Returns true if successful, false otherwise.
102 // 102 //
103 // In posix environment and if |path| is a symbolic link, this deletes only 103 // In posix environment and if |path| is a symbolic link, this deletes only
104 // the symlink. (even if the symlink deferences to a non-existent file) 104 // the symlink. (even if the symlink deferences to a non-existent file)
satorux1 2012/07/10 00:06:54 while you are at it, please s/deferences/points/
yoshiki 2012/07/10 01:31:17 Done.
satorux1 2012/07/10 06:57:17 point -> points
105 // 105 //
106 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT 106 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT
107 // TO "rm -rf", SO USE WITH CAUTION. 107 // TO "rm -rf", SO USE WITH CAUTION.
108 BASE_EXPORT bool Delete(const FilePath& path, bool recursive); 108 BASE_EXPORT bool Delete(const FilePath& path, bool recursive);
109 109
110 #if defined(OS_WIN) 110 #if defined(OS_WIN)
111 // Schedules to delete the given path, whether it's a file or a directory, until 111 // Schedules to delete the given path, whether it's a file or a directory, until
112 // the operating system is restarted. 112 // the operating system is restarted.
113 // Note: 113 // Note:
114 // 1) The file/directory to be deleted should exist in a temp folder. 114 // 1) The file/directory to be deleted should exist in a temp folder.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = S_IRWXU | S_IRWXU | S_IRWXO,
satorux1 2012/07/10 00:06:54 -> S_IRWXU | S_IRWXG | S_IRWXO
yoshiki 2012/07/10 01:31:17 Done.
203 FILE_PERMISSION_USER_MASK = S_IRWXU,
204 FILE_PERMISSION_GROUP_MASK = S_IRWXG,
205 FILE_PERMISSION_OTHERS_MASK = S_IRWXO,
206
207 FILE_PERMISSION_READ_BY_USER = S_IRUSR,
208 FILE_PERMISSION_WRITE_BY_USER = S_IWUSR,
209 FILE_PERMISSION_EXECUTE_BY_USER = S_IXUSR,
210 FILE_PERMISSION_READ_BY_GROUP = S_IRGRP,
211 FILE_PERMISSION_WRITE_BY_GROUP = S_IWGRP,
212 FILE_PERMISSION_EXECUTE_BY_GROUP = S_IXGRP,
213 FILE_PERMISSION_READ_BY_OTHERS = S_IROTH,
214 FILE_PERMISSION_WRITE_BY_OTHERS = S_IWOTH,
215 FILE_PERMISSION_EXECUTE_BY_OTHERS = S_IXOTH,
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.
satorux1 2012/07/10 00:06:54 refers to -> points to
yoshiki 2012/07/10 01:31:17 Done.
satorux1 2012/07/10 06:57:17 points
221 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path,
222 int* mode);
223 // Sets the permission of the given |path|.
satorux1 2012/07/10 00:06:54 If |path| is symbolic link, ...
yoshiki 2012/07/10 01:31:17 Done.
224 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path,
225 int mode);
199 #endif // defined(OS_POSIX) 226 #endif // defined(OS_POSIX)
200 227
201 #if defined(OS_WIN) 228 #if defined(OS_WIN)
202 enum ShortcutOptions { 229 enum ShortcutOptions {
203 SHORTCUT_NO_OPTIONS = 0, 230 SHORTCUT_NO_OPTIONS = 0,
204 // Set DualMode property for Windows 8 Metro-enabled shortcuts. 231 // Set DualMode property for Windows 8 Metro-enabled shortcuts.
205 SHORTCUT_DUAL_MODE = 1 << 0, 232 SHORTCUT_DUAL_MODE = 1 << 0,
206 // Create a new shortcut (overwriting if necessary). 233 // Create a new shortcut (overwriting if necessary).
207 SHORTCUT_CREATE_ALWAYS = 1 << 1, 234 SHORTCUT_CREATE_ALWAYS = 1 << 1,
208 }; 235 };
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 }; 665 };
639 666
640 // Attempts determine the FileSystemType for |path|. 667 // Attempts determine the FileSystemType for |path|.
641 // Returns false if |path| doesn't exist. 668 // Returns false if |path| doesn't exist.
642 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); 669 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
643 #endif 670 #endif
644 671
645 } // namespace file_util 672 } // namespace file_util
646 673
647 #endif // BASE_FILE_UTIL_H_ 674 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | base/file_util_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698