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.file; | 5 library descriptor.file; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import '../../../../../pkg/pathos/lib/path.dart' as path; | 10 import '../../../../../pkg/pathos/lib/path.dart' as path; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 var matchingEntries = contents.where((entry) => | 55 var matchingEntries = contents.where((entry) => |
56 entry.stringName == split.first).toList(); | 56 entry.stringName == split.first).toList(); |
57 | 57 |
58 if (matchingEntries.length == 0) { | 58 if (matchingEntries.length == 0) { |
59 throw "Couldn't find an entry named '${split.first}' within " | 59 throw "Couldn't find an entry named '${split.first}' within " |
60 "$nameDescription."; | 60 "$nameDescription."; |
61 } else if (matchingEntries.length > 1) { | 61 } else if (matchingEntries.length > 1) { |
62 throw "Found multiple entries named '${split.first}' within " | 62 throw "Found multiple entries named '${split.first}' within " |
63 "$nameDescription."; | 63 "$nameDescription."; |
64 } else { | 64 } else { |
65 var remainingPath = split.getRange(1, split.length - 1); | 65 var remainingPath = split.sublist(1); |
66 if (remainingPath.isEmpty) { | 66 if (remainingPath.isEmpty) { |
67 return matchingEntries.first.read(); | 67 return matchingEntries.first.read(); |
68 } else { | 68 } else { |
69 return matchingEntries.first.load(_path.joinAll(remainingPath)); | 69 return matchingEntries.first.load(_path.joinAll(remainingPath)); |
70 } | 70 } |
71 } | 71 } |
72 })); | 72 })); |
73 } | 73 } |
74 | 74 |
75 Stream<List<int>> read() => errorStream("Can't read the contents of " | 75 Stream<List<int>> read() => errorStream("Can't read the contents of " |
(...skipping 11 matching lines...) Expand all Loading... |
87 .replaceFirst('| ', '|-- '); | 87 .replaceFirst('| ', '|-- '); |
88 buffer.writeln(entryString); | 88 buffer.writeln(entryString); |
89 } | 89 } |
90 | 90 |
91 var lastEntryString = prefixLines(contents.last.describe(), prefix: ' ') | 91 var lastEntryString = prefixLines(contents.last.describe(), prefix: ' ') |
92 .replaceFirst(' ', "'-- "); | 92 .replaceFirst(' ', "'-- "); |
93 buffer.write(lastEntryString); | 93 buffer.write(lastEntryString); |
94 return buffer.toString(); | 94 return buffer.toString(); |
95 } | 95 } |
96 } | 96 } |
OLD | NEW |