| 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 "bin/file.h" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { | 116 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { |
| 117 int position = lseek(fd, 0, SEEK_END); | 117 int position = lseek(fd, 0, SEEK_END); |
| 118 if (position < 0) { | 118 if (position < 0) { |
| 119 return NULL; | 119 return NULL; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 return new File(name, new FileHandle(fd)); | 122 return new File(name, new FileHandle(fd)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 File* File::OpenStdio(int fd) { |
| 127 UNREACHABLE(); |
| 128 return NULL; |
| 129 } |
| 130 |
| 131 |
| 126 bool File::Exists(const char* name) { | 132 bool File::Exists(const char* name) { |
| 127 struct stat st; | 133 struct stat st; |
| 128 if (stat(name, &st) == 0) { | 134 if (stat(name, &st) == 0) { |
| 129 return ((st.st_mode & S_IFMT) == S_IFREG); | 135 return ((st.st_mode & S_IFMT) == S_IFREG); |
| 130 } else { | 136 } else { |
| 131 return false; | 137 return false; |
| 132 } | 138 } |
| 133 } | 139 } |
| 134 | 140 |
| 135 | 141 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 176 |
| 171 | 177 |
| 172 const char* File::PathSeparator() { | 178 const char* File::PathSeparator() { |
| 173 return "\\"; | 179 return "\\"; |
| 174 } | 180 } |
| 175 | 181 |
| 176 | 182 |
| 177 const char* File::StringEscapedPathSeparator() { | 183 const char* File::StringEscapedPathSeparator() { |
| 178 return "\\\\"; | 184 return "\\\\"; |
| 179 } | 185 } |
| 186 |
| 187 |
| 188 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 189 // Treat all stdio handles as pipes. The Windows event handler and |
| 190 // socket code will handle the different handle types. |
| 191 return kPipe; |
| 192 } |
| OLD | NEW |