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 library descriptor.directory; | 5 library descriptor.directory; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 var adjective = requiresReadable ? 'readable' : 'loadable'; | 78 var adjective = requiresReadable ? 'readable' : 'loadable'; |
79 if (matchingEntries.length == 0) { | 79 if (matchingEntries.length == 0) { |
80 throw "Couldn't find a $adjective entry named '${split.first}' within " | 80 throw "Couldn't find a $adjective entry named '${split.first}' within " |
81 "'$name'."; | 81 "'$name'."; |
82 } else if (matchingEntries.length > 1) { | 82 } else if (matchingEntries.length > 1) { |
83 throw "Found multiple $adjective entries named '${split.first}' within " | 83 throw "Found multiple $adjective entries named '${split.first}' within " |
84 "'$name'."; | 84 "'$name'."; |
85 } else { | 85 } else { |
86 var remainingPath = split.sublist(1); | 86 var remainingPath = split.sublist(1); |
87 if (remainingPath.isEmpty) { | 87 if (remainingPath.isEmpty) { |
88 return matchingEntries.first.read(); | 88 return (matchingEntries.first as ReadableDescriptor).read(); |
89 } else { | 89 } else { |
90 return matchingEntries.first.load(_path.joinAll(remainingPath)); | 90 return (matchingEntries.first as LoadableDescriptor) |
| 91 .load(_path.joinAll(remainingPath)); |
91 } | 92 } |
92 } | 93 } |
93 })); | 94 })); |
94 } | 95 } |
95 | 96 |
96 String describe() { | 97 String describe() { |
97 if (contents.isEmpty) return name; | 98 if (contents.isEmpty) return name; |
98 | 99 |
99 var buffer = new StringBuffer(); | 100 var buffer = new StringBuffer(); |
100 buffer.writeln(name); | 101 buffer.writeln(name); |
(...skipping 25 matching lines...) Expand all Loading... |
126 | 127 |
127 _DirectoryValidationError(Iterable errors) | 128 _DirectoryValidationError(Iterable errors) |
128 : errors = errors.map((e) => e.toString()).toList(); | 129 : errors = errors.map((e) => e.toString()).toList(); |
129 | 130 |
130 String toString() { | 131 String toString() { |
131 if (errors.length == 1) return errors.single; | 132 if (errors.length == 1) return errors.single; |
132 return errors.map((e) => prefixLines(e, prefix: ' ', firstPrefix: '* ')) | 133 return errors.map((e) => prefixLines(e, prefix: ' ', firstPrefix: '* ')) |
133 .join('\n'); | 134 .join('\n'); |
134 } | 135 } |
135 } | 136 } |
OLD | NEW |