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 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
6 library pub.io; | 6 library pub.io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 controller.addError(e); | 765 controller.addError(e); |
766 controller.close(); | 766 controller.close(); |
767 }); | 767 }); |
768 return new ByteStream(controller.stream); | 768 return new ByteStream(controller.stream); |
769 } | 769 } |
770 | 770 |
771 withTempDir((tempDir) { | 771 withTempDir((tempDir) { |
772 // Create the tar file. | 772 // Create the tar file. |
773 var tarFile = path.join(tempDir, "intermediate.tar"); | 773 var tarFile = path.join(tempDir, "intermediate.tar"); |
774 var args = ["a", "-w$baseDir", tarFile]; | 774 var args = ["a", "-w$baseDir", tarFile]; |
775 args.addAll(contents.map((entry) => '-i!"$entry"')); | 775 args.addAll(contents.map((entry) => '-i!$entry')); |
776 | 776 |
777 // We're passing 'baseDir' both as '-w' and setting it as the working | 777 // We're passing 'baseDir' both as '-w' and setting it as the working |
778 // directory explicitly here intentionally. The former ensures that the | 778 // directory explicitly here intentionally. The former ensures that the |
779 // files added to the archive have the correct relative path in the archive. | 779 // files added to the archive have the correct relative path in the archive. |
780 // The latter enables relative paths in the "-i" args to be resolved. | 780 // The latter enables relative paths in the "-i" args to be resolved. |
781 return runProcess(pathTo7zip, args, workingDir: baseDir).then((_) { | 781 return runProcess(pathTo7zip, args, workingDir: baseDir).then((_) { |
782 // GZIP it. 7zip doesn't support doing both as a single operation. Send | 782 // GZIP it. 7zip doesn't support doing both as a single operation. Send |
783 // the output to stdout. | 783 // the output to stdout. |
784 args = ["a", "unused", "-tgzip", "-so", tarFile]; | 784 args = ["a", "unused", "-tgzip", "-so", tarFile]; |
785 return startProcess(pathTo7zip, args); | 785 return startProcess(pathTo7zip, args); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 818 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
819 | 819 |
820 bool get success => exitCode == 0; | 820 bool get success => exitCode == 0; |
821 } | 821 } |
822 | 822 |
823 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 823 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
824 Uri _getUri(uri) { | 824 Uri _getUri(uri) { |
825 if (uri is Uri) return uri; | 825 if (uri is Uri) return uri; |
826 return Uri.parse(uri); | 826 return Uri.parse(uri); |
827 } | 827 } |
OLD | NEW |