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 #library("reader"); | 5 #library("reader"); |
6 | 6 |
7 #import("input_stream.dart"); | 7 #import("input_stream.dart"); |
8 #import("options.dart"); | 8 #import("options.dart"); |
9 #import("read_request.dart"); | 9 #import("read_request.dart"); |
10 #import("utils.dart"); | 10 #import("utils.dart"); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (format.ar) pending.add(call(SUPPORT_FORMAT_AR, id)); | 118 if (format.ar) pending.add(call(SUPPORT_FORMAT_AR, id)); |
119 if (format.cpio) pending.add(call(SUPPORT_FORMAT_CPIO, id)); | 119 if (format.cpio) pending.add(call(SUPPORT_FORMAT_CPIO, id)); |
120 if (format.empty) pending.add(call(SUPPORT_FORMAT_EMPTY, id)); | 120 if (format.empty) pending.add(call(SUPPORT_FORMAT_EMPTY, id)); |
121 if (format.iso9660) pending.add(call(SUPPORT_FORMAT_ISO9660, id)); | 121 if (format.iso9660) pending.add(call(SUPPORT_FORMAT_ISO9660, id)); |
122 if (format.mtree) pending.add(call(SUPPORT_FORMAT_MTREE, id)); | 122 if (format.mtree) pending.add(call(SUPPORT_FORMAT_MTREE, id)); |
123 if (format.raw) pending.add(call(SUPPORT_FORMAT_RAW, id)); | 123 if (format.raw) pending.add(call(SUPPORT_FORMAT_RAW, id)); |
124 if (format.tar) pending.add(call(SUPPORT_FORMAT_TAR, id)); | 124 if (format.tar) pending.add(call(SUPPORT_FORMAT_TAR, id)); |
125 if (format.zip) pending.add(call(SUPPORT_FORMAT_ZIP, id)); | 125 if (format.zip) pending.add(call(SUPPORT_FORMAT_ZIP, id)); |
126 } | 126 } |
127 | 127 |
128 if (!filter.options.isEmpty) { | 128 var addOption = (request, option) { |
129 pending.add( | 129 var value; |
130 call(SET_FILTER_OPTIONS, id, [filter.options.serialize()])); | 130 if (option.value == false || option.value == null) { |
| 131 value = null; |
| 132 } else if (option.value == true) { |
| 133 value = '1'; |
| 134 } else { |
| 135 value = option.value.toString(); |
| 136 } |
| 137 |
| 138 pending.add(CALL(request, id, [module, option.name, value])); |
| 139 }; |
| 140 |
| 141 for (var option in filter.options.all) { |
| 142 addOption(SET_FILTER_OPTION, option); |
131 } | 143 } |
132 | 144 |
133 if (!format.options.isEmpty) { | 145 for (var option in format.options.all) { |
134 pending.add( | 146 addOption(SET_FORMAT_OPTION, option); |
135 call(SET_FORMAT_OPTIONS, id, [format.options.serialize()])); | |
136 } | 147 } |
137 | 148 |
138 if (!options.isEmpty) { | 149 for (var option in options.all) { |
139 pending.add(call(SET_OPTIONS, id, [options.serialize()])); | 150 addOption(SET_OPTION, option); |
140 } | 151 } |
141 | 152 |
142 return Futures.wait(pending); | 153 return Futures.wait(pending); |
143 } | 154 } |
144 } | 155 } |
145 | 156 |
146 /** | 157 /** |
147 * The configuration for the filter(s) to use when decompressing the contents | 158 * The configuration for the filter(s) to use when decompressing the contents |
148 * of an archive. The precise compression used is auto-detected from among all | 159 * of an archive. The precise compression used is auto-detected from among all |
149 * enabled options. | 160 * enabled options. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 /** | 290 /** |
280 * Options for individual formats. See [the libarchive documentation][wiki] | 291 * Options for individual formats. See [the libarchive documentation][wiki] |
281 * for a list of available options. | 292 * for a list of available options. |
282 * | 293 * |
283 * [wiki]: https://github.com/libarchive/libarchive/wiki/ManPageArchiveReadSet
Options3 | 294 * [wiki]: https://github.com/libarchive/libarchive/wiki/ManPageArchiveReadSet
Options3 |
284 */ | 295 */ |
285 final ArchiveOptions options; | 296 final ArchiveOptions options; |
286 | 297 |
287 Format._() : options = new ArchiveOptions(); | 298 Format._() : options = new ArchiveOptions(); |
288 } | 299 } |
OLD | NEW |