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]; | |
| 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 the [parent] | |
| 24 /// directory. Returns a [Future] that completes after the creation is 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 [this] as an in-memory filesystem and returns a stream of the | |
| 38 /// contents of the entry at [path]. This only works if [this] is a directory | |
|
Bob Nystrom
2013/02/22 22:08:57
"entry at [path]" -> "child entry located at [path
nweiz
2013/02/22 23:05:21
Done.
| |
| 39 /// entry. This operation is not [schedule]d. | |
|
Bob Nystrom
2013/02/22 22:08:57
Given "This only works..." I still feel like there
nweiz
2013/02/22 23:05:21
That would make it impossible to write a class lik
| |
| 40 /// | |
| 41 /// All errors in loading the file will be passed through the returned | |
| 42 /// [Stream]. | |
| 43 Stream<List<int>> load(String path); | |
| 44 | |
| 45 /// Returns the contents of [this] as a stream. This only works if [this] is a | |
| 46 /// file entry. This operation is not [schedule]d. | |
| 47 /// | |
| 48 /// All errors in loading the file will be passed through the returned | |
| 49 /// [Stream]. | |
| 50 Stream<List<int>> read(); | |
| 51 | |
| 52 /// Asserts that the name of the descriptor is a [String] and returns it. | |
| 53 String get stringName { | |
| 54 if (name is String) return name; | |
| 55 throw 'Pattern $nameDescription must be a string.'; | |
| 56 } | |
| 57 | |
| 58 /// Returns a human-readable description of [name], for error reporting. For | |
| 59 /// string names, this will just be the name in quotes; for regular | |
| 60 /// expressions, it will use JavaScript-style `/.../` notation. | |
| 61 String get nameDescription => describePattern(name); | |
| 62 | |
| 63 /// Returns a detailed tree-style description of [this]. | |
| 64 String describe(); | |
| 65 } | |
| OLD | NEW |