| Index: runtime/bin/file_android.cc
 | 
| diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc
 | 
| index cc29740f094e524cddef3672a836566e37de425c..c6729147fb9bfe790f41a351c0ff074eea8bc92f 100644
 | 
| --- a/runtime/bin/file_android.cc
 | 
| +++ b/runtime/bin/file_android.cc
 | 
| @@ -148,7 +148,13 @@ int64_t File::Length() {
 | 
|  }
 | 
|  
 | 
|  
 | 
| -File* File::Open(const char* name, FileOpenMode mode) {
 | 
| +File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) {
 | 
| +  UNREACHABLE();
 | 
| +  return NULL;
 | 
| +}
 | 
| +
 | 
| +
 | 
| +File* File::ScopedOpen(const char* name, FileOpenMode mode) {
 | 
|    // Report errors for non-regular files.
 | 
|    struct stat st;
 | 
|    if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
 | 
| @@ -185,8 +191,16 @@ File* File::Open(const char* name, FileOpenMode mode) {
 | 
|  }
 | 
|  
 | 
|  
 | 
| +File* File::Open(const char* path, FileOpenMode mode) {
 | 
| +  // ScopedOpen doesn't actually need a scope.
 | 
| +  return ScopedOpen(path, mode);
 | 
| +}
 | 
| +
 | 
| +
 | 
|  File* File::OpenStdio(int fd) {
 | 
| -  if (fd < 0 || 2 < fd) return NULL;
 | 
| +  if ((fd < 0) || (2 < fd)) {
 | 
| +    return NULL;
 | 
| +  }
 | 
|    return new File(new FileHandle(fd));
 | 
|  }
 | 
|  
 | 
| @@ -292,7 +306,7 @@ bool File::Copy(const char* old_path, const char* new_path) {
 | 
|      // From sendfile man pages:
 | 
|      //   Applications may wish to fall back to read(2)/write(2) in the case
 | 
|      //   where sendfile() fails with EINVAL or ENOSYS.
 | 
| -    if (result < 0 && (errno == EINVAL || errno == ENOSYS)) {
 | 
| +    if ((result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
 | 
|        const intptr_t kBufferSize = 8 * KB;
 | 
|        uint8_t buffer[kBufferSize];
 | 
|        while ((result = TEMP_FAILURE_RETRY(
 | 
| @@ -363,18 +377,20 @@ time_t File::LastModified(const char* name) {
 | 
|  }
 | 
|  
 | 
|  
 | 
| -char* File::LinkTarget(const char* pathname) {
 | 
| +const char* File::LinkTarget(const char* pathname) {
 | 
|    struct stat link_stats;
 | 
| -  if (lstat(pathname, &link_stats) != 0) return NULL;
 | 
| +  if (lstat(pathname, &link_stats) != 0) {
 | 
| +    return NULL;
 | 
| +  }
 | 
|    if (!S_ISLNK(link_stats.st_mode)) {
 | 
|      errno = ENOENT;
 | 
|      return NULL;
 | 
|    }
 | 
|    size_t target_size = link_stats.st_size;
 | 
| -  char* target_name = reinterpret_cast<char*>(malloc(target_size + 1));
 | 
| +  char* target_name = DartUtils::ScopedCString(target_size + 1);
 | 
| +  ASSERT(target_name != NULL);
 | 
|    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';
 | 
| @@ -387,20 +403,16 @@ bool File::IsAbsolutePath(const char* pathname) {
 | 
|  }
 | 
|  
 | 
|  
 | 
| -char* File::GetCanonicalPath(const char* pathname) {
 | 
| +const char* File::GetCanonicalPath(const char* pathname) {
 | 
|    char* abs_path = NULL;
 | 
|    if (pathname != NULL) {
 | 
| -    // A null second argument to realpath crashes Android.  Fixed in Mar 2013,
 | 
| -    // but not in earlier releases of Android.
 | 
| -    char* resolved = reinterpret_cast<char*>(malloc(PATH_MAX));
 | 
| -    if (resolved == NULL) return NULL;
 | 
| +    char* resolved_path = DartUtils::ScopedCString(PATH_MAX + 1);
 | 
| +    ASSERT(resolved_path != NULL);
 | 
|      do {
 | 
| -      abs_path = realpath(pathname, resolved);
 | 
| -    } while (abs_path == NULL && errno == EINTR);
 | 
| -    ASSERT(abs_path == NULL || IsAbsolutePath(abs_path));
 | 
| -    if (abs_path != resolved) {
 | 
| -      free(resolved);
 | 
| -    }
 | 
| +      abs_path = realpath(pathname, resolved_path);
 | 
| +    } while ((abs_path == NULL) && (errno == EINTR));
 | 
| +    ASSERT((abs_path == NULL) || IsAbsolutePath(abs_path));
 | 
| +    ASSERT((abs_path == NULL) || (abs_path == resolved_path));
 | 
|    }
 | 
|    return abs_path;
 | 
|  }
 | 
| @@ -417,7 +429,7 @@ const char* File::StringEscapedPathSeparator() {
 | 
|  
 | 
|  
 | 
|  File::StdioHandleType File::GetStdioHandleType(int fd) {
 | 
| -  ASSERT(0 <= fd && fd <= 2);
 | 
| +  ASSERT((0 <= fd) && (fd <= 2));
 | 
|    struct stat buf;
 | 
|    int result = fstat(fd, &buf);
 | 
|    if (result == -1) {
 | 
| @@ -426,10 +438,18 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
 | 
|      Utils::StrError(errno, error_message, kBufferSize);
 | 
|      FATAL2("Failed stat on file descriptor %d: %s", fd, error_message);
 | 
|    }
 | 
| -  if (S_ISCHR(buf.st_mode)) return kTerminal;
 | 
| -  if (S_ISFIFO(buf.st_mode)) return kPipe;
 | 
| -  if (S_ISSOCK(buf.st_mode)) return kSocket;
 | 
| -  if (S_ISREG(buf.st_mode)) return kFile;
 | 
| +  if (S_ISCHR(buf.st_mode)) {
 | 
| +    return kTerminal;
 | 
| +  }
 | 
| +  if (S_ISFIFO(buf.st_mode)) {
 | 
| +    return kPipe;
 | 
| +  }
 | 
| +  if (S_ISSOCK(buf.st_mode)) {
 | 
| +    return kSocket;
 | 
| +  }
 | 
| +  if (S_ISREG(buf.st_mode)) {
 | 
| +    return kFile;
 | 
| +  }
 | 
|    return kOther;
 | 
|  }
 | 
|  
 | 
| @@ -442,10 +462,18 @@ File::Type File::GetType(const char* pathname, bool follow_links) {
 | 
|    } else {
 | 
|      stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
 | 
|    }
 | 
| -  if (stat_success == -1) return File::kDoesNotExist;
 | 
| -  if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory;
 | 
| -  if (S_ISREG(entry_info.st_mode)) return File::kIsFile;
 | 
| -  if (S_ISLNK(entry_info.st_mode)) return File::kIsLink;
 | 
| +  if (stat_success == -1) {
 | 
| +    return File::kDoesNotExist;
 | 
| +  }
 | 
| +  if (S_ISDIR(entry_info.st_mode)) {
 | 
| +    return File::kIsDirectory;
 | 
| +  }
 | 
| +  if (S_ISREG(entry_info.st_mode)) {
 | 
| +    return File::kIsFile;
 | 
| +  }
 | 
| +  if (S_ISLNK(entry_info.st_mode)) {
 | 
| +    return File::kIsLink;
 | 
| +  }
 | 
|    return File::kDoesNotExist;
 | 
|  }
 | 
|  
 | 
| @@ -453,12 +481,12 @@ File::Type File::GetType(const char* pathname, bool follow_links) {
 | 
|  File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
 | 
|    struct stat file_1_info;
 | 
|    struct stat file_2_info;
 | 
| -  if (NO_RETRY_EXPECTED(lstat(file_1, &file_1_info)) == -1 ||
 | 
| -      NO_RETRY_EXPECTED(lstat(file_2, &file_2_info)) == -1) {
 | 
| +  if ((NO_RETRY_EXPECTED(lstat(file_1, &file_1_info)) == -1) ||
 | 
| +      (NO_RETRY_EXPECTED(lstat(file_2, &file_2_info)) == -1)) {
 | 
|      return File::kError;
 | 
|    }
 | 
| -  return (file_1_info.st_ino == file_2_info.st_ino &&
 | 
| -          file_1_info.st_dev == file_2_info.st_dev) ?
 | 
| +  return ((file_1_info.st_ino == file_2_info.st_ino) &&
 | 
| +          (file_1_info.st_dev == file_2_info.st_dev)) ?
 | 
|        File::kIdentical :
 | 
|        File::kDifferent;
 | 
|  }
 | 
| 
 |