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

Side by Side Diff: runtime/bin/file_fuchsia.cc

Issue 2856913004: [Fuchsia] Allows non-regular files to be opened. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/tests/vm/dart/hello_fuchsia_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | runtime/tests/vm/dart/hello_fuchsia_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698