Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1049)

Side by Side Diff: pkg/scheduled_test/lib/src/descriptor/entry.dart

Issue 12330062: Add a filesystem descriptor library to scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 child entry located at [path]. This only works if [this]
39 /// is a directory entry. This operation is not [schedule]d.
40 ///
41 /// All errors in loading the file will be passed through the returned
42 /// [Stream].
43 Stream<List<int>> load(String pathToLoad) => errorStream("Can't load "
44 "'$pathToLoad' from within $nameDescription: not a directory.");
45
46 /// Returns the contents of [this] as a stream. This only works if [this] is a
47 /// file entry. This operation is not [schedule]d.
48 ///
49 /// All errors in loading the file will be passed through the returned
50 /// [Stream].
51 Stream<List<int>> read();
52
53 /// Asserts that the name of the descriptor is a [String] and returns it.
54 String get stringName {
55 if (name is String) return name;
56 throw 'Pattern $nameDescription must be a string.';
57 }
58
59 /// Returns a human-readable description of [name], for error reporting. For
60 /// string names, this will just be the name in quotes; for regular
61 /// expressions, it will use JavaScript-style `/.../` notation.
62 String get nameDescription => describePattern(name);
63
64 /// Returns a detailed tree-style description of [this].
65 String describe();
66 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/directory.dart ('k') | pkg/scheduled_test/lib/src/descriptor/file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698