| 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 part of pipeline; |
| 6 |
| 5 List stdout, stderr, log; | 7 List stdout, stderr, log; |
| 6 var replyPort; | 8 var replyPort; |
| 7 int _procId = 1; | 9 int _procId = 1; |
| 8 Map _procs = {}; | 10 Map _procs = {}; |
| 9 | 11 |
| 10 /** | 12 /** |
| 11 * Create a file path for a temporary file. The file will be in the | 13 * Create a file path for a temporary file. The file will be in the |
| 12 * [tmpDir] directory, with name [basis], but with any extension | 14 * [tmpDir] directory, with name [basis], but with any extension |
| 13 * stripped and replaced by [suffix]. | 15 * stripped and replaced by [suffix]. |
| 14 */ | 16 */ |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 Process p = _procs.remove(id); | 122 Process p = _procs.remove(id); |
| 121 p.kill(); | 123 p.kill(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 /** Delete a file named [fname] if it exists. */ | 126 /** Delete a file named [fname] if it exists. */ |
| 125 bool cleanup(String fname) { | 127 bool cleanup(String fname) { |
| 126 if (fname != null && !config['keep-files']) { | 128 if (fname != null && !config['keep-files']) { |
| 127 var f = new File(fname); | 129 var f = new File(fname); |
| 128 try { | 130 try { |
| 129 if (f.existsSync()) { | 131 if (f.existsSync()) { |
| 132 logMessage('Removing $fname'); |
| 130 f.deleteSync(); | 133 f.deleteSync(); |
| 131 } | 134 } |
| 132 } catch (e) { | 135 } catch (e) { |
| 133 return false; | 136 return false; |
| 134 } | 137 } |
| 135 } | 138 } |
| 136 return true; | 139 return true; |
| 137 } | 140 } |
| 138 | 141 |
| 139 initPipeline(port) { | 142 initPipeline(port) { |
| 140 replyPort = port; | 143 replyPort = port; |
| 141 stdout = new List(); | 144 stdout = new List(); |
| 142 stderr = new List(); | 145 stderr = new List(); |
| 143 log = new List(); | 146 log = new List(); |
| 144 } | 147 } |
| 145 | 148 |
| 146 void completePipeline([exitCode = 0]) { | 149 void completePipeline([exitCode = 0]) { |
| 147 replyPort.send([stdout, stderr, log, exitCode]); | 150 replyPort.send([stdout, stderr, log, exitCode]); |
| 148 } | 151 } |
| 149 | 152 |
| 150 /** Utility function to log diagnostic messages. */ | 153 /** Utility function to log diagnostic messages. */ |
| 151 void logMessage(msg) => log.add(msg); | 154 void logMessage(msg) => log.add(msg); |
| OLD | NEW |