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

Side by Side Diff: pkg/front_end/lib/file_system.dart

Issue 2844903002: Extend file-system abstraction with a couple methods, remove context (Closed)
Patch Set: v3 Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/lib/kernel_generator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 front_end.file_system; 5 library front_end.file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as path;
10
11 /// Abstract interface to file system operations. 9 /// Abstract interface to file system operations.
12 /// 10 ///
13 /// All front end interaction with the file system goes through this interface; 11 /// All front end interaction with the file system goes through this interface;
14 /// this makes it possible for clients to use the front end in a way that 12 /// this makes it possible for clients to use the front end in a way that
15 /// doesn't require file system access (e.g. to run unit tests, or to run 13 /// doesn't require file system access (e.g. to run unit tests, or to run
16 /// inside a browser). 14 /// inside a browser).
17 /// 15 ///
18 /// Not intended to be implemented or extended by clients. 16 /// Not intended to be implemented or extended by clients.
19 abstract class FileSystem { 17 abstract class FileSystem {
20 /// Returns a path context suitable for use with this [FileSystem].
21 ///
22 /// TODO(paulberry): try to eliminate all usages of this. Since the
23 /// FileSystem API now uses URIs rather than paths, it should not be needed.
24 path.Context get context;
Siggi Cherem (dart-lang) 2017/04/27 00:08:50 I can split this change if you prefer, but very so
25
26 /// Returns a [FileSystemEntity] corresponding to the given [uri]. 18 /// Returns a [FileSystemEntity] corresponding to the given [uri].
27 /// 19 ///
28 /// Uses of `..` and `.` in the URI are normalized before returning. 20 /// Uses of `..` and `.` in the URI are normalized before returning.
29 /// 21 ///
30 /// If the URI scheme is not supported by this file system, an [Error] will be 22 /// If the URI scheme is not supported by this file system, an [Error] will be
31 /// thrown. 23 /// thrown.
32 /// 24 ///
33 /// Does not check whether a file or folder exists at the given location. 25 /// Does not check whether a file or folder exists at the given location.
34 FileSystemEntity entityForUri(Uri uri); 26 FileSystemEntity entityForUri(Uri uri);
35 } 27 }
36 28
37 /// Abstract representation of a file system entity that may or may not exist. 29 /// Abstract representation of a file system entity that may or may not exist.
38 /// 30 ///
39 /// Instances of this class have suitable implementations of equality tests and 31 /// Instances of this class have suitable implementations of equality tests and
40 /// hashCode. 32 /// hashCode.
41 /// 33 ///
42 /// Not intended to be implemented or extended by clients. 34 /// Not intended to be implemented or extended by clients.
43 abstract class FileSystemEntity { 35 abstract class FileSystemEntity {
44 /// Returns the absolute normalized URI represented by this file system 36 /// The absolute normalized URI represented by this file system entity.
45 /// entity.
46 /// 37 ///
47 /// Note: this is not necessarily the same as the URI that was passed to 38 /// Note: this is not necessarily the same as the URI that was passed to
48 /// [FileSystem.entityForUri], since the URI might have been normalized. 39 /// [FileSystem.entityForUri], since the URI might have been normalized.
49 Uri get uri; 40 Uri get uri;
50 41
51 /// Attempts to access this file system entity as a file and read its contents 42 /// Attempts to access this file system entity as a file and read its contents
52 /// as raw bytes. 43 /// as raw bytes.
53 /// 44 ///
54 /// If an error occurs while attempting to read the file (e.g. because no such 45 /// If an error occurs while attempting to read the file (e.g. because no such
55 /// file exists, or the entity is a directory), the future is completed with 46 /// file exists, or the entity is a directory), the future is completed with
56 /// an [Exception]. 47 /// an [Exception].
57 Future<List<int>> readAsBytes(); 48 Future<List<int>> readAsBytes();
58 49
59 /// Attempts to access this file system entity as a file and read its contents 50 /// Attempts to access this file system entity as a file and read its contents
60 /// as a string. 51 /// as a string.
61 /// 52 ///
62 /// The file is assumed to be UTF-8 encoded. 53 /// The file is assumed to be UTF-8 encoded.
63 /// 54 ///
64 /// If an error occurs while attempting to read the file (e.g. because no such 55 /// If an error occurs while attempting to read the file (e.g. because no such
65 /// file exists, the entity is a directory, or the file is not valid UTF-8), 56 /// file exists, the entity is a directory, or the file is not valid UTF-8),
66 /// the future is completed with an [Exception]. 57 /// the future is completed with an [Exception].
67 Future<String> readAsString(); 58 Future<String> readAsString();
59
60 /// Whether this file system entity exists.
61 Future<bool> exists();
62
63 /// Extracts the last-modification time of the file system entity, if it
64 /// exists and it is a file, otherwise the future is completed with an
65 /// [Exception].
66 Future<DateTime> lastModified();
68 } 67 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/kernel_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698