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

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

Issue 2439173002: [windows] Make most file_win.cc functions use malloc for string conversions. (Closed)
Patch Set: Fix typo Created 4 years, 1 month 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 | « runtime/bin/file_android.cc ('k') | runtime/bin/file_linux.cc » ('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(TARGET_OS_FUCHSIA) 6 #if defined(TARGET_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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return -1; 157 return -1;
158 } 158 }
159 159
160 160
161 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) { 161 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) {
162 UNREACHABLE(); 162 UNREACHABLE();
163 return NULL; 163 return NULL;
164 } 164 }
165 165
166 166
167 File* File::ScopedOpen(const char* name, FileOpenMode mode) { 167 File* File::Open(const char* name, FileOpenMode mode) {
168 // Report errors for non-regular files. 168 // Report errors for non-regular files.
169 struct stat st; 169 struct stat st;
170 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 170 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
171 if (!S_ISREG(st.st_mode)) { 171 if (!S_ISREG(st.st_mode)) {
172 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; 172 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT;
173 return NULL; 173 return NULL;
174 } 174 }
175 } 175 }
176 int flags = O_RDONLY; 176 int flags = O_RDONLY;
177 if ((mode & kWrite) != 0) { 177 if ((mode & kWrite) != 0) {
(...skipping 16 matching lines...) Expand all
194 (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) { 194 (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) {
195 int64_t position = lseek(fd, 0, SEEK_END); 195 int64_t position = lseek(fd, 0, SEEK_END);
196 if (position < 0) { 196 if (position < 0) {
197 return NULL; 197 return NULL;
198 } 198 }
199 } 199 }
200 return new File(new FileHandle(fd)); 200 return new File(new FileHandle(fd));
201 } 201 }
202 202
203 203
204 File* File::Open(const char* path, FileOpenMode mode) {
205 // ScopedOpen doesn't actually need a scope.
206 return ScopedOpen(path, mode);
207 }
208
209
210 File* File::OpenStdio(int fd) { 204 File* File::OpenStdio(int fd) {
211 return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd)); 205 return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd));
212 } 206 }
213 207
214 208
215 bool File::Exists(const char* name) { 209 bool File::Exists(const char* name) {
216 struct stat st; 210 struct stat st;
217 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 211 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
218 return S_ISREG(st.st_mode); 212 return S_ISREG(st.st_mode);
219 } else { 213 } else {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return ((file_1_info.st_ino == file_2_info.st_ino) && 437 return ((file_1_info.st_ino == file_2_info.st_ino) &&
444 (file_1_info.st_dev == file_2_info.st_dev)) ? 438 (file_1_info.st_dev == file_2_info.st_dev)) ?
445 File::kIdentical : 439 File::kIdentical :
446 File::kDifferent; 440 File::kDifferent;
447 } 441 }
448 442
449 } // namespace bin 443 } // namespace bin
450 } // namespace dart 444 } // namespace dart
451 445
452 #endif // defined(TARGET_OS_FUCHSIA) 446 #endif // defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698