Chromium Code Reviews| Index: base/file_util_posix.cc |
| diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc |
| index e0a1a55e066738e8f1d9025324a4825e58d96c05..3fbc6d648aa6c02b6a628093292f9129e483ee64 100644 |
| --- a/base/file_util_posix.cc |
| +++ b/base/file_util_posix.cc |
| @@ -373,6 +373,28 @@ bool ReadFromFD(int fd, char* buffer, size_t bytes) { |
| return total_read == bytes; |
| } |
| +bool CreateSymbolicLink(const FilePath& target_path, |
| + const FilePath& symlink_path) { |
| + DCHECK(!symlink_path.empty()); |
| + DCHECK(!target_path.empty()); |
| + return ::symlink(target_path.value().c_str(), |
| + symlink_path.value().c_str()) != -1; |
| +} |
| + |
| +bool ReadSymbolicLink(const FilePath& symlink_path, |
| + FilePath* target_path) { |
| + DCHECK(!symlink_path.empty()); |
| + DCHECK(target_path); |
| + char buf[PATH_MAX]; |
| + ssize_t count = ::readlink(symlink_path.value().c_str(), buf, arraysize(buf)); |
| + if (count > 0) { |
|
Evan Martin
2010/11/29 21:21:14
Consider an early return pattern here instead (if
Greg Spencer (Chromium)
2010/11/29 21:34:11
Done.
|
| + *target_path = FilePath(FilePath::StringType(buf, count)); |
|
Evan Martin
2010/11/29 21:21:14
Can use std::string here, since we know the string
Greg Spencer (Chromium)
2010/11/29 21:34:11
I prefer to use the actual type that FilePath expe
|
| + } else { |
| + 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. |