OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library front_end.file_system; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'package:path/path.dart' as path; | |
10 | |
11 /// Abstract interface to file system operations. | |
12 /// | |
13 /// 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 | |
15 /// doesn't require file system access (e.g. to run unit tests, or to run | |
16 /// inside a browser). | |
17 /// | |
18 /// Not intended to be implemented or extended by clients. | |
19 abstract class FileSystem { | |
20 /// Returns a path context suitable for use with this [FileSystem]. | |
21 path.Context get context; | |
22 | |
23 /// Returns a [FileSystemEntity] corresponding to the given [path]. | |
24 /// | |
25 /// Uses of `..` and `.` in path are normalized before returning (so, for | |
26 /// example, `entityForPath('./foo')` and `entityForPath('foo')` are | |
27 /// equivalent). | |
28 /// | |
29 /// Does not check whether a file or folder exists at the given location. | |
30 FileSystemEntity entityForPath(String path); | |
31 | |
32 /// Returns a [FileSystemEntity] corresponding to the given [uri]. | |
33 /// | |
34 /// Uses of `..` and `.` in the URI are normalized before returning. | |
35 /// | |
36 /// If [uri] is not a `file:` URI, an [Error] will be thrown. | |
37 /// | |
38 /// Does not check whether a file or folder exists at the given location. | |
39 FileSystemEntity entityForUri(Uri uri); | |
40 } | |
41 | |
42 /// Abstract representation of a file system entity that may or may not exist. | |
43 /// | |
44 /// Not intended to be implemented or extended by clients. | |
45 abstract class FileSystemEntity { | |
46 /// Returns the absolute path represented by this file system entity. | |
scheglov
2016/10/18 20:43:40
A small tweak.
/User/foo/../bar/baz.dart is absolu
Paul Berry
2016/10/18 21:09:39
Done. I also modified the documentation on `entit
| |
47 /// | |
48 /// Note: if the [FileSystemEntity] was created using | |
49 /// [FileSystem.entityForPath], this is not necessarily the same as the path | |
50 /// that was used to create the object, since the path my have been | |
scheglov
2016/10/18 20:43:40
"my have", "might have"?
Paul Berry
2016/10/18 21:09:39
Done.
| |
51 /// normalized. | |
52 String get path; | |
53 | |
54 /// Returns a `file:` URI representing this file system entity. | |
scheglov
2016/10/18 20:43:40
It still does not answer my question, whether this
Paul Berry
2016/10/18 21:09:39
After some discussion, we decided to remove this g
| |
55 /// | |
56 /// Note: if the [FileSystemEntity] was created using | |
57 /// [FileSystem.entityForUri], this is not necessarily the same as the Uri | |
58 /// that was used to create the object, since the Uri my have been normalized. | |
scheglov
2016/10/18 20:43:40
Same here my/might.
Paul Berry
2016/10/18 21:09:39
Acknowledged.
| |
59 Uri get uri; | |
60 | |
61 /// Attempts to access this file system entity as a file and read its contents | |
62 /// as raw bytes. | |
63 /// | |
64 /// If an error occurs while attempting to read the file (e.g. because no such | |
65 /// file exists, or the entity is a directory), the future is completed with | |
66 /// an [Exception]. | |
67 Future<List<int>> readBytes(); | |
Brian Wilkerson
2016/10/18 20:52:03
I still think this should be consistent with dart:
Paul Berry
2016/10/18 21:09:39
Done.
| |
68 | |
69 /// Attempts to access this file system entity as a file and read its contents | |
70 /// as a string. | |
71 /// | |
72 /// The file is assumed to be UTF-8 encoded. | |
73 /// | |
74 /// If an error occurs while attempting to read the file (e.g. because no such | |
75 /// file exists, or the entity is a directory), the future is completed with | |
76 /// an [Exception]. | |
77 Future<String> readString(); | |
78 } | |
OLD | NEW |