| 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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 if (baseDir == null) baseDir = path.current; | 1005 if (baseDir == null) baseDir = path.current; |
| 1006 baseDir = path.absolute(baseDir); | 1006 baseDir = path.absolute(baseDir); |
| 1007 contents = contents.map((entry) { | 1007 contents = contents.map((entry) { |
| 1008 entry = path.absolute(entry); | 1008 entry = path.absolute(entry); |
| 1009 if (!path.isWithin(baseDir, entry)) { | 1009 if (!path.isWithin(baseDir, entry)) { |
| 1010 throw new ArgumentError('Entry $entry is not inside $baseDir.'); | 1010 throw new ArgumentError('Entry $entry is not inside $baseDir.'); |
| 1011 } | 1011 } |
| 1012 return path.relative(entry, from: baseDir); | 1012 return path.relative(entry, from: baseDir); |
| 1013 }).toList(); | 1013 }).toList(); |
| 1014 | 1014 |
| 1015 if (Platform.operatingSystem != "windows") { | 1015 if (!Platform.isWindows) { |
| 1016 var args = [ | 1016 var args = [ |
| 1017 // ustar is the most recent tar format that's compatible across all | 1017 // ustar is the most recent tar format that's compatible across all |
| 1018 // OSes. | 1018 // OSes. |
| 1019 "--format=ustar", | 1019 "--format=ustar", |
| 1020 "--create", | 1020 "--create", |
| 1021 "--gzip", | 1021 "--gzip", |
| 1022 "--directory", | 1022 "--directory", |
| 1023 baseDir, | 1023 baseDir, |
| 1024 "--files-from", | 1024 "--files-from", |
| 1025 "/dev/stdin" | 1025 "/dev/stdin" |
| 1026 ]; | 1026 ]; |
| 1027 | 1027 |
| 1028 // The ustar format doesn't support large UIDs, which can happen if |
| 1029 // someone's using Active Directory on Linux. We don't care about |
| 1030 // preserving ownership anyway, so we just set them to 0. Note that BSD |
| 1031 // tar doesn't support the `--owner` or `--group` arguments. |
| 1032 if (Platform.isLinux) args.addAll(["--owner=0", "--group=0"]); |
| 1033 |
| 1028 var process = await startProcess("tar", args); | 1034 var process = await startProcess("tar", args); |
| 1029 process.stdin.add(UTF8.encode(contents.join("\n"))); | 1035 process.stdin.add(UTF8.encode(contents.join("\n"))); |
| 1030 process.stdin.close(); | 1036 process.stdin.close(); |
| 1031 return process.stdout; | 1037 return process.stdout; |
| 1032 } | 1038 } |
| 1033 | 1039 |
| 1034 // Don't use [withTempDir] here because we don't want to delete the temp | 1040 // Don't use [withTempDir] here because we don't want to delete the temp |
| 1035 // directory until the returned stream has closed. | 1041 // directory until the returned stream has closed. |
| 1036 var tempDir = createSystemTempDir(); | 1042 var tempDir = createSystemTempDir(); |
| 1037 | 1043 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 | 1082 |
| 1077 // TODO(rnystrom): Remove this and change to returning one string. | 1083 // TODO(rnystrom): Remove this and change to returning one string. |
| 1078 static List<String> _toLines(String output) { | 1084 static List<String> _toLines(String output) { |
| 1079 var lines = splitLines(output); | 1085 var lines = splitLines(output); |
| 1080 if (!lines.isEmpty && lines.last == "") lines.removeLast(); | 1086 if (!lines.isEmpty && lines.last == "") lines.removeLast(); |
| 1081 return lines; | 1087 return lines; |
| 1082 } | 1088 } |
| 1083 | 1089 |
| 1084 bool get success => exitCode == exit_codes.SUCCESS; | 1090 bool get success => exitCode == exit_codes.SUCCESS; |
| 1085 } | 1091 } |
| OLD | NEW |