Chromium Code Reviews| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 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. | |
| 197 struct stat st; | |
| 198 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | |
|
zra
2017/04/26 17:34:13
Could you explain why this is needed?
This change
| |
| 199 if (!S_ISREG(st.st_mode)) { | |
| 200 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; | |
| 201 return NULL; | |
| 202 } | |
| 203 } | |
| 204 int flags = O_RDONLY; | 196 int flags = O_RDONLY; |
| 205 if ((mode & kWrite) != 0) { | 197 if ((mode & kWrite) != 0) { |
| 206 ASSERT((mode & kWriteOnly) == 0); | 198 ASSERT((mode & kWriteOnly) == 0); |
| 207 flags = (O_RDWR | O_CREAT); | 199 flags = (O_RDWR | O_CREAT); |
| 208 } | 200 } |
| 209 if ((mode & kWriteOnly) != 0) { | 201 if ((mode & kWriteOnly) != 0) { |
| 210 ASSERT((mode & kWrite) == 0); | 202 ASSERT((mode & kWrite) == 0); |
| 211 flags = (O_WRONLY | O_CREAT); | 203 flags = (O_WRONLY | O_CREAT); |
| 212 } | 204 } |
| 213 if ((mode & kTruncate) != 0) { | 205 if ((mode & kTruncate) != 0) { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 return ((file_1_info.st_ino == file_2_info.st_ino) && | 561 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 570 (file_1_info.st_dev == file_2_info.st_dev)) | 562 (file_1_info.st_dev == file_2_info.st_dev)) |
| 571 ? File::kIdentical | 563 ? File::kIdentical |
| 572 : File::kDifferent; | 564 : File::kDifferent; |
| 573 } | 565 } |
| 574 | 566 |
| 575 } // namespace bin | 567 } // namespace bin |
| 576 } // namespace dart | 568 } // namespace dart |
| 577 | 569 |
| 578 #endif // defined(HOST_OS_FUCHSIA) | 570 #endif // defined(HOST_OS_FUCHSIA) |
| OLD | NEW |