| 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 library android; | 5 library android; |
| 6 | 6 |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "dart:async"; | 8 import "dart:async"; |
| 9 import "dart:core"; | 9 import "dart:core"; |
| 10 import "dart:utf"; | 10 import "dart:utf"; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * [_executeCommandRaw] will write [stdin] to the standard input of the created | 28 * [_executeCommandRaw] will write [stdin] to the standard input of the created |
| 29 * process and will return a tuple (stdout, stderr). | 29 * process and will return a tuple (stdout, stderr). |
| 30 * | 30 * |
| 31 * If the exit code of the process was nonzero it will complete with an error. | 31 * If the exit code of the process was nonzero it will complete with an error. |
| 32 * If starting the process failed, it will complete with an error as well. | 32 * If starting the process failed, it will complete with an error as well. |
| 33 */ | 33 */ |
| 34 Future _executeCommandRaw(String executable, | 34 Future _executeCommandRaw(String executable, |
| 35 List<String> args, | 35 List<String> args, |
| 36 [String stdin = ""]) { | 36 [String stdin = ""]) { |
| 37 Future<String> getOutput(Stream<List<int>> stream) { | 37 Future<String> getOutput(Stream<List<int>> stream) { |
| 38 return stream.transform(new StringDecoder()) | 38 return stream.transform(new StringDecoder()).toList() |
| 39 .reduce(new StringBuffer(), (buf, data) { | 39 .then((data) => data.join("")); |
| 40 buf.write(data); | |
| 41 return buf; | |
| 42 }).then((buf) => buf.toString()); | |
| 43 } | 40 } |
| 44 | 41 |
| 45 DebugLogger.info("Running: '\$ $executable ${args.join(' ')}'"); | 42 DebugLogger.info("Running: '\$ $executable ${args.join(' ')}'"); |
| 46 return Process.start(executable, args).then((Process process) { | 43 return Process.start(executable, args).then((Process process) { |
| 47 if (stdin != null && stdin != '') { | 44 if (stdin != null && stdin != '') { |
| 48 process.stdin.write(stdin); | 45 process.stdin.write(stdin); |
| 49 } | 46 } |
| 50 process.stdin.close(); | 47 process.stdin.close(); |
| 51 | 48 |
| 52 var futures = [getOutput(process.stdout), | 49 var futures = [getOutput(process.stdout), |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 */ | 315 */ |
| 319 class Intent { | 316 class Intent { |
| 320 String action; | 317 String action; |
| 321 String package; | 318 String package; |
| 322 String activity; | 319 String activity; |
| 323 String dataUri; | 320 String dataUri; |
| 324 | 321 |
| 325 Intent(this.action, this.package, this.activity, [this.dataUri]); | 322 Intent(this.action, this.package, this.activity, [this.dataUri]); |
| 326 } | 323 } |
| 327 | 324 |
| OLD | NEW |