Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 int flags = O_RDONLY; | 116 int flags = O_RDONLY; |
| 117 if ((mode & kWrite) != 0) { | 117 if ((mode & kWrite) != 0) { |
| 118 flags = (O_RDWR | O_CREAT); | 118 flags = (O_RDWR | O_CREAT); |
| 119 } | 119 } |
| 120 if ((mode & kTruncate) != 0) { | 120 if ((mode & kTruncate) != 0) { |
| 121 flags = flags | O_TRUNC; | 121 flags = flags | O_TRUNC; |
| 122 } | 122 } |
| 123 flags |= O_CLOEXEC; | 123 flags |= O_CLOEXEC; |
| 124 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); | 124 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); |
| 125 if (fd < 0) { | 125 if (fd < 0) { |
| 126 printf("Open failed\n"); | |
|
Søren Gjesse
2013/03/12 08:54:09
Debug print :-).
Anders Johnsen
2013/03/12 10:04:59
Oops, bad merge :)
| |
| 126 return NULL; | 127 return NULL; |
| 127 } | 128 } |
| 128 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { | 129 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { |
| 129 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END)); | 130 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END)); |
| 130 if (position < 0) { | 131 if (position < 0) { |
| 131 return NULL; | 132 return NULL; |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 return new File(new FileHandle(fd)); | 135 return new File(new FileHandle(fd)); |
| 135 } | 136 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); | 258 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); |
| 258 } | 259 } |
| 259 if (stat_success == -1) return File::kDoesNotExist; | 260 if (stat_success == -1) return File::kDoesNotExist; |
| 260 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; | 261 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; |
| 261 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; | 262 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; |
| 262 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; | 263 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; |
| 263 return File::kDoesNotExist; | 264 return File::kDoesNotExist; |
| 264 } | 265 } |
| 265 | 266 |
| 266 #endif // defined(TARGET_OS_LINUX) | 267 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |