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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; | 7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; |
8 const int _STDIO_HANDLE_TYPE_PIPE = 1; | 8 const int _STDIO_HANDLE_TYPE_PIPE = 1; |
9 const int _STDIO_HANDLE_TYPE_FILE = 2; | 9 const int _STDIO_HANDLE_TYPE_FILE = 2; |
10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; | 10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 * terminator. Default is `false`. | 50 * terminator. Default is `false`. |
51 * | 51 * |
52 * If end-of-file is reached after any bytes have been read from stdin, | 52 * If end-of-file is reached after any bytes have been read from stdin, |
53 * that data is returned. | 53 * that data is returned. |
54 * Returns `null` if no bytes preceeded the end of input. | 54 * Returns `null` if no bytes preceeded the end of input. |
55 */ | 55 */ |
56 String readLineSync({Encoding encoding: SYSTEM_ENCODING, | 56 String readLineSync({Encoding encoding: SYSTEM_ENCODING, |
57 bool retainNewlines: false}) { | 57 bool retainNewlines: false}) { |
58 const CR = 13; | 58 const CR = 13; |
59 const LF = 10; | 59 const LF = 10; |
60 final List<int> line = <int>[]; | 60 final List line = []; |
61 // On Windows, if lineMode is disabled, only CR is received. | 61 // On Windows, if lineMode is disabled, only CR is received. |
62 bool crIsNewline = Platform.isWindows && | 62 bool crIsNewline = Platform.isWindows && |
63 (stdioType(stdin) == StdioType.TERMINAL) && | 63 (stdioType(stdin) == StdioType.TERMINAL) && |
64 !lineMode; | 64 !lineMode; |
65 if (retainNewlines) { | 65 if (retainNewlines) { |
66 int byte; | 66 int byte; |
67 do { | 67 do { |
68 byte = readByteSync(); | 68 byte = readByteSync(); |
69 if (byte < 0) { | 69 if (byte < 0) { |
70 break; | 70 break; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 } | 352 } |
353 | 353 |
354 | 354 |
355 class _StdIOUtils { | 355 class _StdIOUtils { |
356 external static _getStdioOutputStream(int fd); | 356 external static _getStdioOutputStream(int fd); |
357 external static Stdin _getStdioInputStream(); | 357 external static Stdin _getStdioInputStream(); |
358 /// Returns the socket type or `null` if [socket] is not a builtin socket. | 358 /// Returns the socket type or `null` if [socket] is not a builtin socket. |
359 external static int _socketType(Socket socket); | 359 external static int _socketType(Socket socket); |
360 external static _getStdioHandleType(int fd); | 360 external static _getStdioHandleType(int fd); |
361 } | 361 } |
OLD | NEW |