Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: runtime/bin/directory_fuchsia.cc

Issue 2259613002: [fuchsia] Fix build. Build packages/ output. Add Directory::Exists(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/BUILD.gn ('k') | runtime/vm/os_fuchsia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
« no previous file with comments | « runtime/bin/BUILD.gn ('k') | runtime/vm/os_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698