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 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 contents = contents.map((entry) { | 997 contents = contents.map((entry) { |
998 entry = path.absolute(entry); | 998 entry = path.absolute(entry); |
999 if (!path.isWithin(baseDir, entry)) { | 999 if (!path.isWithin(baseDir, entry)) { |
1000 throw new ArgumentError('Entry $entry is not inside $baseDir.'); | 1000 throw new ArgumentError('Entry $entry is not inside $baseDir.'); |
1001 } | 1001 } |
1002 return path.relative(entry, from: baseDir); | 1002 return path.relative(entry, from: baseDir); |
1003 }).toList(); | 1003 }).toList(); |
1004 | 1004 |
1005 if (Platform.operatingSystem != "windows") { | 1005 if (Platform.operatingSystem != "windows") { |
1006 var args = [ | 1006 var args = [ |
| 1007 // ustar is the most recent tar format that's compatible across all |
| 1008 // OSes. |
| 1009 "--format=ustar", |
1007 "--create", | 1010 "--create", |
1008 "--gzip", | 1011 "--gzip", |
1009 "--directory", | 1012 "--directory", |
1010 baseDir, | 1013 baseDir, |
1011 "--files-from", | 1014 "--files-from", |
1012 "/dev/stdin" | 1015 "/dev/stdin" |
1013 ]; | 1016 ]; |
1014 | 1017 |
1015 var process = await startProcess("tar", args); | 1018 var process = await startProcess("tar", args); |
1016 process.stdin.add(UTF8.encode(contents.join("\n"))); | 1019 process.stdin.add(UTF8.encode(contents.join("\n"))); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 | 1066 |
1064 // TODO(rnystrom): Remove this and change to returning one string. | 1067 // TODO(rnystrom): Remove this and change to returning one string. |
1065 static List<String> _toLines(String output) { | 1068 static List<String> _toLines(String output) { |
1066 var lines = splitLines(output); | 1069 var lines = splitLines(output); |
1067 if (!lines.isEmpty && lines.last == "") lines.removeLast(); | 1070 if (!lines.isEmpty && lines.last == "") lines.removeLast(); |
1068 return lines; | 1071 return lines; |
1069 } | 1072 } |
1070 | 1073 |
1071 bool get success => exitCode == exit_codes.SUCCESS; | 1074 bool get success => exitCode == exit_codes.SUCCESS; |
1072 } | 1075 } |
OLD | NEW |