| 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.descriptor; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 /// The base class for various declarative descriptions of filesystem entries. | |
| 10 /// All asynchronous operations on descriptors are [schedule]d unless otherwise | |
| 11 /// noted. | |
| 12 abstract class Descriptor { | |
| 13 /// The name of this entry. | |
| 14 final String name; | |
| 15 | |
| 16 Descriptor(this.name); | |
| 17 | |
| 18 /// Schedules the creation of the described entry within the [parent] | |
| 19 /// directory. Returns a [Future] that completes after the creation is done. | |
| 20 /// | |
| 21 /// [parent] defaults to [defaultRoot]. | |
| 22 Future create([String parent]); | |
| 23 | |
| 24 /// Schedules the validation of the described entry. This validates that the | |
| 25 /// physical file system under [parent] contains an entry that matches the one | |
| 26 /// described by [this]. Returns a [Future] that completes to `null` if the | |
| 27 /// entry is valid, or throws an error if it failed. | |
| 28 /// | |
| 29 /// [parent] defaults to [defaultRoot]. | |
| 30 Future validate([String parent]); | |
| 31 | |
| 32 /// An unscheduled version of [validate]. This is useful if validation errors | |
| 33 /// need to be caught, since otherwise they'd be registered by the schedule. | |
| 34 Future validateNow([String parent]); | |
| 35 | |
| 36 /// Returns a detailed tree-style description of [this]. | |
| 37 String describe(); | |
| 38 } | |
| 39 | |
| 40 /// An interface for descriptors that can load the contents of sub-descriptors. | |
| 41 abstract class LoadableDescriptor implements Descriptor { | |
| 42 /// Treats [this] as an in-memory filesystem and returns a stream of the | |
| 43 /// contents of the child entry located at [path]. This only works if [this] | |
| 44 /// is a directory entry. This operation is not [schedule]d. | |
| 45 /// | |
| 46 /// This method uses POSIX paths regardless of the underlying operating | |
| 47 /// system. | |
| 48 /// | |
| 49 /// All errors in loading the file will be passed through the returned | |
| 50 /// [Stream]. | |
| 51 Stream<List<int>> load(String pathToLoad); | |
| 52 } | |
| 53 | |
| 54 /// An interface for descriptors whose contents can be read. | |
| 55 abstract class ReadableDescriptor implements Descriptor { | |
| 56 /// Returns the contents of [this] as a stream. This only works if [this] is a | |
| 57 /// file entry. This operation is not [schedule]d. | |
| 58 /// | |
| 59 /// All errors in loading the file will be passed through the returned | |
| 60 /// [Stream]. | |
| 61 Stream<List<int>> read(); | |
| 62 } | |
| OLD | NEW |