| Index: runtime/bin/file_linux.cc
|
| diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
|
| index abbe9cce2ac942ffd242da705d6251059738b0f5..c3ee9d07d61aff3a49c72448f4bfef18b2bc6d4d 100644
|
| --- a/runtime/bin/file_linux.cc
|
| +++ b/runtime/bin/file_linux.cc
|
| @@ -193,6 +193,23 @@ time_t File::LastModified(const char* name) {
|
| }
|
|
|
|
|
| +char* File::LinkTarget(const char* pathname) {
|
| + struct stat link_stats;
|
| + if (lstat(pathname, &link_stats) != 0) return NULL;
|
| + // TODO(whesse): return a better error than LinkIOException(OSError) here.
|
| + if (!S_ISLNK(link_stats.st_mode)) return NULL;
|
| + size_t target_size = link_stats.st_size;
|
| + char* target_name = reinterpret_cast<char*>(malloc(target_size + 1));
|
| + size_t read_size = readlink(pathname, target_name, target_size + 1);
|
| + if (read_size != target_size) {
|
| + free(target_name);
|
| + return NULL;
|
| + }
|
| + target_name[target_size] = '\0';
|
| + return target_name;
|
| +}
|
| +
|
| +
|
| bool File::IsAbsolutePath(const char* pathname) {
|
| return (pathname != NULL && pathname[0] == '/');
|
| }
|
|
|