| Index: runtime/bin/directory_fuchsia.cc
|
| diff --git a/runtime/bin/directory_fuchsia.cc b/runtime/bin/directory_fuchsia.cc
|
| index a1387b07fc75eba821ca0eda88b270c31d633f77..1e374d1617e5189f5bf0377d9dd3013bfd61bcd2 100644
|
| --- a/runtime/bin/directory_fuchsia.cc
|
| +++ b/runtime/bin/directory_fuchsia.cc
|
| @@ -10,8 +10,14 @@
|
| #include <errno.h> // NOLINT
|
| #include <stdlib.h> // NOLINT
|
| #include <string.h> // NOLINT
|
| +#include <sys/stat.h> // NOLINT
|
| #include <unistd.h> // NOLINT
|
|
|
| +#include "bin/dartutils.h"
|
| +#include "bin/file.h"
|
| +#include "bin/platform.h"
|
| +#include "platform/signal_blocker.h"
|
| +
|
| namespace dart {
|
| namespace bin {
|
|
|
| @@ -94,8 +100,31 @@ void DirectoryListingEntry::ResetLink() {
|
|
|
|
|
| Directory::ExistsResult Directory::Exists(const char* dir_name) {
|
| - UNIMPLEMENTED();
|
| - return UNKNOWN;
|
| + struct stat entry_info;
|
| + int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info));
|
| + if (success == 0) {
|
| + if (S_ISDIR(entry_info.st_mode)) {
|
| + return EXISTS;
|
| + } else {
|
| + return DOES_NOT_EXIST;
|
| + }
|
| + } else {
|
| + if ((errno == EACCES) ||
|
| + (errno == EBADF) ||
|
| + (errno == EFAULT) ||
|
| + (errno == ENOMEM) ||
|
| + (errno == EOVERFLOW)) {
|
| + // Search permissions denied for one of the directories in the
|
| + // path or a low level error occured. We do not know if the
|
| + // directory exists.
|
| + return UNKNOWN;
|
| + }
|
| + ASSERT((errno == ELOOP) ||
|
| + (errno == ENAMETOOLONG) ||
|
| + (errno == ENOENT) ||
|
| + (errno == ENOTDIR));
|
| + return DOES_NOT_EXIST;
|
| + }
|
| }
|
|
|
|
|
|
|