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

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

Issue 2439173002: [windows] Make most file_win.cc functions use malloc for string conversions. (Closed)
Patch Set: Fix typo Created 4 years, 2 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 | « runtime/bin/file_fuchsia.cc ('k') | runtime/bin/file_macos.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return -1; 175 return -1;
176 } 176 }
177 177
178 178
179 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) { 179 File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) {
180 UNREACHABLE(); 180 UNREACHABLE();
181 return NULL; 181 return NULL;
182 } 182 }
183 183
184 184
185 File* File::ScopedOpen(const char* name, FileOpenMode mode) { 185 File* File::Open(const char* name, FileOpenMode mode) {
186 // Report errors for non-regular files. 186 // Report errors for non-regular files.
187 struct stat64 st; 187 struct stat64 st;
188 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { 188 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) {
189 // Only accept regular files, character devices, and pipes. 189 // Only accept regular files, character devices, and pipes.
190 if (!S_ISREG(st.st_mode) && !S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) { 190 if (!S_ISREG(st.st_mode) && !S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) {
191 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; 191 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT;
192 return NULL; 192 return NULL;
193 } 193 }
194 } 194 }
195 int flags = O_RDONLY; 195 int flags = O_RDONLY;
(...skipping 17 matching lines...) Expand all
213 (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) { 213 (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) {
214 int64_t position = NO_RETRY_EXPECTED(lseek64(fd, 0, SEEK_END)); 214 int64_t position = NO_RETRY_EXPECTED(lseek64(fd, 0, SEEK_END));
215 if (position < 0) { 215 if (position < 0) {
216 return NULL; 216 return NULL;
217 } 217 }
218 } 218 }
219 return new File(new FileHandle(fd)); 219 return new File(new FileHandle(fd));
220 } 220 }
221 221
222 222
223 File* File::Open(const char* path, FileOpenMode mode) {
224 // ScopedOpen doesn't actually need a scope.
225 return ScopedOpen(path, mode);
226 }
227
228
229 File* File::OpenStdio(int fd) { 223 File* File::OpenStdio(int fd) {
230 return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd)); 224 return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd));
231 } 225 }
232 226
233 227
234 bool File::Exists(const char* name) { 228 bool File::Exists(const char* name) {
235 struct stat64 st; 229 struct stat64 st;
236 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { 230 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) {
237 return S_ISREG(st.st_mode); 231 return S_ISREG(st.st_mode);
238 } else { 232 } else {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return ((file_1_info.st_ino == file_2_info.st_ino) && 520 return ((file_1_info.st_ino == file_2_info.st_ino) &&
527 (file_1_info.st_dev == file_2_info.st_dev)) ? 521 (file_1_info.st_dev == file_2_info.st_dev)) ?
528 File::kIdentical : 522 File::kIdentical :
529 File::kDifferent; 523 File::kDifferent;
530 } 524 }
531 525
532 } // namespace bin 526 } // namespace bin
533 } // namespace dart 527 } // namespace dart
534 528
535 #endif // defined(TARGET_OS_LINUX) 529 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/file_fuchsia.cc ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698