OLD | NEW |
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; | 9 import 'package:path/path.dart' as path; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 /// | 24 /// |
25 /// Uses of `..` and `.` in path are normalized before returning (so, for | 25 /// Uses of `..` and `.` in path are normalized before returning (so, for |
26 /// example, `entityForPath('./foo')` and `entityForPath('foo')` are | 26 /// example, `entityForPath('./foo')` and `entityForPath('foo')` are |
27 /// equivalent). Relative paths are also converted to absolute paths. | 27 /// equivalent). Relative paths are also converted to absolute paths. |
28 /// | 28 /// |
29 /// Does not check whether a file or folder exists at the given location. | 29 /// Does not check whether a file or folder exists at the given location. |
30 FileSystemEntity entityForPath(String path); | 30 FileSystemEntity entityForPath(String path); |
31 | 31 |
32 /// Returns a [FileSystemEntity] corresponding to the given [uri]. | 32 /// Returns a [FileSystemEntity] corresponding to the given [uri]. |
33 /// | 33 /// |
34 /// Uses of `..` and `.` in the URI are normalized before returning. Relative | 34 /// Uses of `..` and `.` in the URI are normalized before returning. |
35 /// paths are also converted to absolute paths. | |
36 /// | 35 /// |
37 /// If [uri] is not a `file:` URI, an [Error] will be thrown. | 36 /// If [uri] is not an absolute `file:` URI, an [Error] will be thrown. |
38 /// | 37 /// |
39 /// Does not check whether a file or folder exists at the given location. | 38 /// Does not check whether a file or folder exists at the given location. |
40 FileSystemEntity entityForUri(Uri uri); | 39 FileSystemEntity entityForUri(Uri uri); |
41 } | 40 } |
42 | 41 |
43 /// Abstract representation of a file system entity that may or may not exist. | 42 /// Abstract representation of a file system entity that may or may not exist. |
44 /// | 43 /// |
| 44 /// Instances of this class have suitable implementations of equality tests and |
| 45 /// hashCode. |
| 46 /// |
45 /// Not intended to be implemented or extended by clients. | 47 /// Not intended to be implemented or extended by clients. |
46 abstract class FileSystemEntity { | 48 abstract class FileSystemEntity { |
47 /// Returns the absolute normalized path represented by this file system | 49 /// Returns the absolute normalized path represented by this file system |
48 /// entity. | 50 /// entity. |
49 /// | 51 /// |
50 /// Note: if the [FileSystemEntity] was created using | 52 /// Note: if the [FileSystemEntity] was created using |
51 /// [FileSystem.entityForPath], this is not necessarily the same as the path | 53 /// [FileSystem.entityForPath], this is not necessarily the same as the path |
52 /// that was used to create the object, since the path might have been | 54 /// that was used to create the object, since the path might have been |
53 /// normalized. | 55 /// normalized. |
54 String get path; | 56 String get path; |
55 | 57 |
56 /// Attempts to access this file system entity as a file and read its contents | 58 /// Attempts to access this file system entity as a file and read its contents |
57 /// as raw bytes. | 59 /// as raw bytes. |
58 /// | 60 /// |
59 /// If an error occurs while attempting to read the file (e.g. because no such | 61 /// If an error occurs while attempting to read the file (e.g. because no such |
60 /// file exists, or the entity is a directory), the future is completed with | 62 /// file exists, or the entity is a directory), the future is completed with |
61 /// an [Exception]. | 63 /// an [Exception]. |
62 Future<List<int>> readAsBytes(); | 64 Future<List<int>> readAsBytes(); |
63 | 65 |
64 /// Attempts to access this file system entity as a file and read its contents | 66 /// Attempts to access this file system entity as a file and read its contents |
65 /// as a string. | 67 /// as a string. |
66 /// | 68 /// |
67 /// The file is assumed to be UTF-8 encoded. | 69 /// The file is assumed to be UTF-8 encoded. |
68 /// | 70 /// |
69 /// If an error occurs while attempting to read the file (e.g. because no such | 71 /// If an error occurs while attempting to read the file (e.g. because no such |
70 /// file exists, or the entity is a directory), the future is completed with | 72 /// file exists, the entity is a directory, or the file is not valid UTF-8), |
71 /// an [Exception]. | 73 /// the future is completed with an [Exception]. |
72 Future<String> readAsString(); | 74 Future<String> readAsString(); |
73 } | 75 } |
OLD | NEW |