OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
7 | 7 |
8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
11 #include <stdlib.h> // NOLINT | 11 #include <stdlib.h> // NOLINT |
12 #include <string.h> // NOLINT | 12 #include <string.h> // NOLINT |
| 13 #include <sys/stat.h> // NOLINT |
13 #include <unistd.h> // NOLINT | 14 #include <unistd.h> // NOLINT |
14 | 15 |
| 16 #include "bin/dartutils.h" |
| 17 #include "bin/file.h" |
| 18 #include "bin/platform.h" |
| 19 #include "platform/signal_blocker.h" |
| 20 |
15 namespace dart { | 21 namespace dart { |
16 namespace bin { | 22 namespace bin { |
17 | 23 |
18 PathBuffer::PathBuffer() : length_(0) { | 24 PathBuffer::PathBuffer() : length_(0) { |
19 data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT | 25 data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT |
20 } | 26 } |
21 | 27 |
22 | 28 |
23 PathBuffer::~PathBuffer() { | 29 PathBuffer::~PathBuffer() { |
24 free(data_); | 30 free(data_); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 UNIMPLEMENTED(); | 93 UNIMPLEMENTED(); |
88 } | 94 } |
89 | 95 |
90 | 96 |
91 void DirectoryListingEntry::ResetLink() { | 97 void DirectoryListingEntry::ResetLink() { |
92 UNIMPLEMENTED(); | 98 UNIMPLEMENTED(); |
93 } | 99 } |
94 | 100 |
95 | 101 |
96 Directory::ExistsResult Directory::Exists(const char* dir_name) { | 102 Directory::ExistsResult Directory::Exists(const char* dir_name) { |
97 UNIMPLEMENTED(); | 103 struct stat entry_info; |
98 return UNKNOWN; | 104 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info)); |
| 105 if (success == 0) { |
| 106 if (S_ISDIR(entry_info.st_mode)) { |
| 107 return EXISTS; |
| 108 } else { |
| 109 return DOES_NOT_EXIST; |
| 110 } |
| 111 } else { |
| 112 if ((errno == EACCES) || |
| 113 (errno == EBADF) || |
| 114 (errno == EFAULT) || |
| 115 (errno == ENOMEM) || |
| 116 (errno == EOVERFLOW)) { |
| 117 // Search permissions denied for one of the directories in the |
| 118 // path or a low level error occured. We do not know if the |
| 119 // directory exists. |
| 120 return UNKNOWN; |
| 121 } |
| 122 ASSERT((errno == ELOOP) || |
| 123 (errno == ENAMETOOLONG) || |
| 124 (errno == ENOENT) || |
| 125 (errno == ENOTDIR)); |
| 126 return DOES_NOT_EXIST; |
| 127 } |
99 } | 128 } |
100 | 129 |
101 | 130 |
102 char* Directory::CurrentNoScope() { | 131 char* Directory::CurrentNoScope() { |
103 return getcwd(NULL, 0); | 132 return getcwd(NULL, 0); |
104 } | 133 } |
105 | 134 |
106 | 135 |
107 const char* Directory::Current() { | 136 const char* Directory::Current() { |
108 char buffer[PATH_MAX]; | 137 char buffer[PATH_MAX]; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 174 |
146 bool Directory::Rename(const char* path, const char* new_path) { | 175 bool Directory::Rename(const char* path, const char* new_path) { |
147 UNIMPLEMENTED(); | 176 UNIMPLEMENTED(); |
148 return false; | 177 return false; |
149 } | 178 } |
150 | 179 |
151 } // namespace bin | 180 } // namespace bin |
152 } // namespace dart | 181 } // namespace dart |
153 | 182 |
154 #endif // defined(TARGET_OS_LINUX) | 183 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |