Chromium Code Reviews| 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; | 5 part of pipeline; |
| 6 | 6 |
| 7 List stdout, stderr, log; | 7 List stdout, stderr, log; |
| 8 var replyPort; | 8 var replyPort; |
| 9 int _procId = 1; | 9 int _procId = 1; |
| 10 Map _procs = {}; | 10 Map _procs = {}; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * 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 |
| 14 * [tmpDir] directory, with name [basis], but with any extension | 14 * [tmpDir] directory, with name [basis], but with any extension |
| 15 * stripped and replaced by [suffix]. | 15 * stripped and replaced by [suffix]. |
| 16 */ | 16 */ |
| 17 String createTempName(String tmpDir, String basis, String suffix) { | 17 String createTempName(String tmpDir, String basis, String suffix) { |
| 18 var p = new Path(basis); | 18 var p = new Path(basis); |
| 19 return '$tmpDir${Platform.pathSeparator}' | 19 return '$tmpDir${Platform.pathSeparator}' |
| 20 '${p.filenameWithoutExtension}${suffix}'; | 20 '${p.filenameWithoutExtension}${suffix}'; |
| 21 } | 21 } |
| 22 | 22 |
| 23 /** | |
| 24 * Given a file path [file], make it absolute if it is relative, | |
| 25 * and return the result as a [Path]. | |
| 26 */ | |
| 27 Path getAbsolutePath(String file) { | |
| 28 var p = new Path(file).canonicalize(); | |
| 29 if (p.isAbsolute) { | |
| 30 return p; | |
| 31 } else { | |
| 32 var cwd = new Path((new Directory.current()).path); | |
| 33 return cwd.join(p); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 /** Get the directory that contains a [file]. */ | |
| 38 String getDirectory(String file) => getAbsolutePath(file).directoryPath.toString (); | |
|
Siggi Cherem (dart-lang)
2012/10/10 17:51:32
80 col
gram
2012/10/17 00:03:28
Done.
| |
| 39 | |
| 23 /** Create a file [fileName] and populate it with [contents]. */ | 40 /** Create a file [fileName] and populate it with [contents]. */ |
| 24 void writeFile(String fileName, String contents) { | 41 void writeFile(String fileName, String contents) { |
| 25 var file = new File(fileName); | 42 var file = new File(fileName); |
| 26 var ostream = file.openOutputStream(FileMode.WRITE); | 43 var ostream = file.openOutputStream(FileMode.WRITE); |
| 27 ostream.writeString(contents); | 44 ostream.writeString(contents); |
| 28 ostream.close(); | 45 ostream.close(); |
| 29 } | 46 } |
| 30 | 47 |
| 31 /* | 48 /* |
| 32 * Run an external process [cmd] with command line arguments [args]. | 49 * Run an external process [cmd] with command line arguments [args]. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 stderr = new List(); | 162 stderr = new List(); |
| 146 log = new List(); | 163 log = new List(); |
| 147 } | 164 } |
| 148 | 165 |
| 149 void completePipeline([exitCode = 0]) { | 166 void completePipeline([exitCode = 0]) { |
| 150 replyPort.send([stdout, stderr, log, exitCode]); | 167 replyPort.send([stdout, stderr, log, exitCode]); |
| 151 } | 168 } |
| 152 | 169 |
| 153 /** Utility function to log diagnostic messages. */ | 170 /** Utility function to log diagnostic messages. */ |
| 154 void logMessage(msg) => log.add(msg); | 171 void logMessage(msg) => log.add(msg); |
| OLD | NEW |