Chromium Code Reviews| Index: base/file_util_posix.cc |
| diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc |
| index e3bab95dd8e32554c81d8b41466909e5406e0027..96760832b5b1f19f2de15987f2395be87d3b8eb7 100644 |
| --- a/base/file_util_posix.cc |
| +++ b/base/file_util_posix.cc |
| @@ -457,6 +457,39 @@ bool ReadSymbolicLink(const FilePath& symlink_path, |
| return true; |
| } |
| +bool GetPosixFilePermissions(const FilePath& path, mode_t* mode) { |
| + base::ThreadRestrictions::AssertIOAllowed(); |
| + DCHECK(mode); |
| + |
| + stat_wrapper_t file_info; |
| + if (CallStat(path.value().c_str(), &file_info) != 0) |
|
satorux1
2012/07/03 06:16:55
i think there is a reason not to use lstat here. p
yoshiki
2012/07/04 07:57:57
Done.
|
| + return false; |
| + |
| + *mode = file_info.st_mode; |
| + return true; |
| +} |
| + |
| +bool ChangePosixFilePermissions(const FilePath& path, |
| + mode_t mode_bits_to_set, |
| + mode_t mode_bits_to_clear) { |
| + base::ThreadRestrictions::AssertIOAllowed(); |
| + DCHECK(!(mode_bits_to_set & mode_bits_to_clear)) |
| + << "Can't set and clear the same bits."; |
| + |
| + stat_wrapper_t stat_buf; |
| + if (CallLstat(path.value().c_str(), &stat_buf) != 0) |
|
satorux1
2012/07/03 06:16:55
why lstat? it seems lstat on symbolic link is inva
satorux1
2012/07/03 06:22:36
invalid for permission bits
yoshiki
2012/07/04 07:57:57
Sorry, I made a mistake.
On 2012/07/03 06:16:55,
|
| + return false; |
| + |
| + mode_t updated_mode_bits = stat_buf.st_mode; |
| + updated_mode_bits |= mode_bits_to_set; |
| + updated_mode_bits &= ~mode_bits_to_clear; |
| + |
| + if (chmod(path.value().c_str(), updated_mode_bits) != 0) |
|
satorux1
2012/07/03 06:23:29
please use HANDLE_EINTR when you call a system cal
yoshiki
2012/07/04 07:57:57
Done.
|
| + return false; |
| + |
| + return true; |
| +} |
| + |
| // Creates and opens a temporary file in |directory|, returning the |
| // file descriptor. |path| is set to the temporary file path. |
| // This function does NOT unlink() the file. |