OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 switch (GetFileType(handle->handle())) { | 188 switch (GetFileType(handle->handle())) { |
189 case FILE_TYPE_CHAR: return File::kTerminal; | 189 case FILE_TYPE_CHAR: return File::kTerminal; |
190 case FILE_TYPE_PIPE: return File::kPipe; | 190 case FILE_TYPE_PIPE: return File::kPipe; |
191 case FILE_TYPE_DISK: return File::kFile; | 191 case FILE_TYPE_DISK: return File::kFile; |
192 default: return GetLastError == NO_ERROR ? File::kOther : -1; | 192 default: return GetLastError == NO_ERROR ? File::kOther : -1; |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 intptr_t Socket::GetStdioHandle(intptr_t num) { | 197 intptr_t Socket::GetStdioHandle(intptr_t num) { |
198 HANDLE handle; | 198 if (num != 0) return -1; |
199 switch (num) { | 199 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); |
200 case 0: | |
201 handle = GetStdHandle(STD_INPUT_HANDLE); | |
202 break; | |
203 case 1: | |
204 handle = GetStdHandle(STD_OUTPUT_HANDLE); | |
205 break; | |
206 case 2: | |
207 handle = GetStdHandle(STD_ERROR_HANDLE); | |
208 break; | |
209 default: UNREACHABLE(); | |
210 } | |
211 if (handle == INVALID_HANDLE_VALUE) { | 200 if (handle == INVALID_HANDLE_VALUE) { |
212 return -1; | 201 return -1; |
213 } | 202 } |
214 StdHandle* std_handle = new StdHandle(handle); | 203 StdHandle* std_handle = new StdHandle(handle); |
215 if (std_handle == NULL) return -1; | |
216 std_handle->MarkDoesNotSupportOverlappedIO(); | 204 std_handle->MarkDoesNotSupportOverlappedIO(); |
217 std_handle->EnsureInitialized(EventHandler::delegate()); | 205 std_handle->EnsureInitialized(EventHandler::delegate()); |
218 return reinterpret_cast<intptr_t>(std_handle); | 206 return reinterpret_cast<intptr_t>(std_handle); |
219 } | 207 } |
220 | 208 |
221 | 209 |
222 intptr_t ServerSocket::Accept(intptr_t fd) { | 210 intptr_t ServerSocket::Accept(intptr_t fd) { |
223 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd); | 211 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd); |
224 ClientSocket* client_socket = listen_socket->Accept(); | 212 ClientSocket* client_socket = listen_socket->Accept(); |
225 if (client_socket != NULL) { | 213 if (client_socket != NULL) { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 proto, | 636 proto, |
649 MCAST_LEAVE_GROUP, | 637 MCAST_LEAVE_GROUP, |
650 reinterpret_cast<char *>(&mreq), | 638 reinterpret_cast<char *>(&mreq), |
651 sizeof(mreq)) == 0; | 639 sizeof(mreq)) == 0; |
652 } | 640 } |
653 | 641 |
654 } // namespace bin | 642 } // namespace bin |
655 } // namespace dart | 643 } // namespace dart |
656 | 644 |
657 #endif // defined(TARGET_OS_WINDOWS) | 645 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |