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

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

Issue 2844493004: Allow fuchsia to open non-regular files. (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 | no next file » | 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698