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(HOST_OS_FUCHSIA) | 6 #if defined(HOST_OS_FUCHSIA) |
7 | 7 |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) { | 189 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) { |
190 UNREACHABLE(); | 190 UNREACHABLE(); |
191 return NULL; | 191 return NULL; |
192 } | 192 } |
193 | 193 |
194 | 194 |
195 File* File::Open(const char* name, FileOpenMode mode) { | 195 File* File::Open(const char* name, FileOpenMode mode) { |
196 // Report errors for non-regular files. | 196 // Report errors for non-regular files. |
197 struct stat st; | 197 struct stat st; |
198 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | 198 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { |
199 if (!S_ISREG(st.st_mode)) { | 199 if (S_ISDIR(st.st_mode)) { |
200 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; | 200 errno = EISDIR; |
201 return NULL; | 201 return NULL; |
202 } | 202 } |
203 } | 203 } |
204 int flags = O_RDONLY; | 204 int flags = O_RDONLY; |
205 if ((mode & kWrite) != 0) { | 205 if ((mode & kWrite) != 0) { |
206 ASSERT((mode & kWriteOnly) == 0); | 206 ASSERT((mode & kWriteOnly) == 0); |
207 flags = (O_RDWR | O_CREAT); | 207 flags = (O_RDWR | O_CREAT); |
208 } | 208 } |
209 if ((mode & kWriteOnly) != 0) { | 209 if ((mode & kWriteOnly) != 0) { |
210 ASSERT((mode & kWrite) == 0); | 210 ASSERT((mode & kWrite) == 0); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return ((file_1_info.st_ino == file_2_info.st_ino) && | 569 return ((file_1_info.st_ino == file_2_info.st_ino) && |
570 (file_1_info.st_dev == file_2_info.st_dev)) | 570 (file_1_info.st_dev == file_2_info.st_dev)) |
571 ? File::kIdentical | 571 ? File::kIdentical |
572 : File::kDifferent; | 572 : File::kDifferent; |
573 } | 573 } |
574 | 574 |
575 } // namespace bin | 575 } // namespace bin |
576 } // namespace dart | 576 } // namespace dart |
577 | 577 |
578 #endif // defined(HOST_OS_FUCHSIA) | 578 #endif // defined(HOST_OS_FUCHSIA) |
OLD | NEW |