| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 package_config.discovery; | 5 library package_config.discovery; |
| 6 | 6 |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 import "dart:typed_data" show Uint8List; | 9 import "dart:typed_data" show Uint8List; |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 assert(location is Directory); | 172 assert(location is Directory); |
| 173 return new FilePackagesDirectoryPackages(location); | 173 return new FilePackagesDirectoryPackages(location); |
| 174 } | 174 } |
| 175 | 175 |
| 176 /// Finds a package resolution strategy for a Dart script. | 176 /// Finds a package resolution strategy for a Dart script. |
| 177 /// | 177 /// |
| 178 /// The [nonFileUri] points to either a Dart script or the directory of the | 178 /// The [nonFileUri] points to either a Dart script or the directory of the |
| 179 /// script. | 179 /// script. |
| 180 /// The [nonFileUri] should not be a `file:` URI since the algorithm for | 180 /// The [nonFileUri] should not be a `file:` URI since the algorithm for |
| 181 /// finding a package resolution strategy is more elaborate for `file:` URIs. | 181 /// finding a package resolution strategy is more elaborate for `file:` URIs. |
| 182 /// In that case, use [findPackagesFile]. | 182 /// In that case, use [findPackagesFromFile]. |
| 183 /// | 183 /// |
| 184 /// This function first tries to locate a `.packages` file in the [nonFileUri] | 184 /// This function first tries to locate a `.packages` file in the [nonFileUri] |
| 185 /// directory. If that is not found, it instead assumes a `packages/` directory | 185 /// directory. If that is not found, it instead assumes a `packages/` directory |
| 186 /// in the same place. | 186 /// in the same place. |
| 187 /// | 187 /// |
| 188 /// By default, this function only works for `http:` and `https:` URIs. | 188 /// By default, this function only works for `http:` and `https:` URIs. |
| 189 /// To support other schemes, a loader must be provided, which is used to | 189 /// To support other schemes, a loader must be provided, which is used to |
| 190 /// try to load the `.packages` file. The loader should return the contents | 190 /// try to load the `.packages` file. The loader should return the contents |
| 191 /// of the requested `.packages` file as bytes, which will be assumed to be | 191 /// of the requested `.packages` file as bytes, which will be assumed to be |
| 192 /// UTF-8 encoded. | 192 /// UTF-8 encoded. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 219 totalLength += list.length; | 219 totalLength += list.length; |
| 220 } | 220 } |
| 221 Uint8List result = new Uint8List(totalLength); | 221 Uint8List result = new Uint8List(totalLength); |
| 222 int offset = 0; | 222 int offset = 0; |
| 223 for (List<int> contentPart in splitContent) { | 223 for (List<int> contentPart in splitContent) { |
| 224 result.setRange(offset, offset + contentPart.length, contentPart); | 224 result.setRange(offset, offset + contentPart.length, contentPart); |
| 225 offset += contentPart.length; | 225 offset += contentPart.length; |
| 226 } | 226 } |
| 227 return result; | 227 return result; |
| 228 } | 228 } |
| OLD | NEW |