Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library descriptor.entry; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'utils.dart'; | |
| 10 | |
| 11 /// The base class for various declarative descriptions of filesystem entries. | |
| 12 /// All asynchronous operations on descriptors are [schedule]d unless otherwise | |
| 13 /// noted. | |
| 14 abstract class Entry { | |
| 15 /// The name of this entry. For most operations, this must be a [String; | |
|
Bob Nystrom
2013/02/22 17:58:21
].
nweiz
2013/02/22 20:57:20
Done.
| |
| 16 /// however, if the entry will only be used for validation, it may be a | |
| 17 /// non-[String] [Pattern]. In this case, there must be only one entry | |
| 18 /// matching it in the physical filesystem for validation to succeed. | |
| 19 final Pattern name; | |
| 20 | |
| 21 Entry(this.name); | |
| 22 | |
| 23 /// Schedules the creation of the described entry within [parent]. Returns a | |
|
Bob Nystrom
2013/02/22 17:58:21
[parent] -> the [parent] directory
nweiz
2013/02/22 20:57:20
Done.
| |
| 24 /// [Future] that is completed after the creation is done. | |
|
Bob Nystrom
2013/02/22 17:58:21
is completed -> completes
nweiz
2013/02/22 20:57:20
Done.
| |
| 25 /// | |
| 26 /// [parent] defaults to [defaultRoot]. | |
| 27 Future create([String parent]); | |
| 28 | |
| 29 /// Schedules the validation of the described entry. This validates that the | |
| 30 /// physical file system under [parent] contains an entry that matches the one | |
| 31 /// described by [this]. Returns a [Future] that completes to `null` if the | |
| 32 /// entry is valid, or throws an error if it failed. | |
| 33 /// | |
| 34 /// [parent] defaults to [defaultRoot]. | |
| 35 Future validate([String parent]); | |
| 36 | |
| 37 /// Treats the [Descriptor] as an in-memory filesystem and returns a stream of | |
| 38 /// the contents of the entry at [path]. This operation is not [schedule]d. | |
| 39 /// | |
| 40 /// If [this] represents a directory, [path] should be a path within that | |
| 41 /// directory. If this represents a file, [path] should be `null`, and the | |
| 42 /// contents of the file will be loaded. | |
|
Bob Nystrom
2013/02/22 17:58:21
This feels like two conceptually different methods
nweiz
2013/02/22 20:57:20
I think it's important that there not be methods s
| |
| 43 /// | |
| 44 /// All errors in loading the file will be passed through the returned | |
| 45 /// [Stream]. | |
| 46 Stream<List<int>> load([String path]); | |
| 47 | |
| 48 /// Asserts that the name of the descriptor is a [String] and returns it. | |
| 49 String get stringName { | |
| 50 if (name is String) return name; | |
| 51 throw 'Pattern $nameDescription must be a string.'; | |
| 52 } | |
| 53 | |
| 54 /// Returns a human-readable description of [name], for error reporting. For | |
| 55 /// string names, this will just be the name in quotes; for regular | |
| 56 /// expressions, it will use JavaScript-style `/.../` notation. | |
| 57 String get nameDescription => describePattern(name); | |
| 58 | |
| 59 /// Returns a detailed tree-style description of [this]. | |
| 60 String describe(); | |
| 61 } | |
| OLD | NEW |