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.physical_file_system; | 5 library front_end.physical_file_system; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'file_system.dart'; | 10 import 'file_system.dart'; |
11 | 11 |
12 /// Concrete implementation of [FileSystem] which performs its operations using | 12 /// Concrete implementation of [FileSystem] which performs its operations using |
13 /// I/O. | 13 /// I/O. |
14 /// | 14 /// |
15 /// Not intended to be implemented or extended by clients. | 15 /// Not intended to be implemented or extended by clients. |
16 class PhysicalFileSystem implements FileSystem { | 16 class PhysicalFileSystem implements FileSystem { |
17 static final PhysicalFileSystem instance = new PhysicalFileSystem._(); | 17 static final PhysicalFileSystem instance = new PhysicalFileSystem._(); |
18 | 18 |
19 PhysicalFileSystem._(); | 19 PhysicalFileSystem._(); |
20 | 20 |
21 @override | 21 @override |
22 FileSystemEntity entityForUri(Uri uri) { | 22 FileSystemEntity entityForUri(Uri uri) { |
23 if (uri.scheme != 'file' && uri.scheme != '') { | 23 if (uri.scheme != 'file' && uri.scheme != '') { |
24 throw new ArgumentError('File URI expected'); | 24 throw new FileSystemException( |
| 25 uri, 'PhysicalFileSystem only supports file:* URIs'); |
25 } | 26 } |
26 return new _PhysicalFileSystemEntity(Uri.base.resolveUri(uri)); | 27 return new _PhysicalFileSystemEntity(Uri.base.resolveUri(uri)); |
27 } | 28 } |
28 } | 29 } |
29 | 30 |
30 /// Concrete implementation of [FileSystemEntity] for use by | 31 /// Concrete implementation of [FileSystemEntity] for use by |
31 /// [PhysicalFileSystem]. | 32 /// [PhysicalFileSystem]. |
32 class _PhysicalFileSystemEntity implements FileSystemEntity { | 33 class _PhysicalFileSystemEntity implements FileSystemEntity { |
33 @override | 34 @override |
34 final Uri uri; | 35 final Uri uri; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 */ | 75 */ |
75 FileSystemException _toFileSystemException(io.FileSystemException exception) { | 76 FileSystemException _toFileSystemException(io.FileSystemException exception) { |
76 String message = exception.message; | 77 String message = exception.message; |
77 String osMessage = exception.osError?.message; | 78 String osMessage = exception.osError?.message; |
78 if (osMessage != null && osMessage.isNotEmpty) { | 79 if (osMessage != null && osMessage.isNotEmpty) { |
79 message = osMessage; | 80 message = osMessage; |
80 } | 81 } |
81 return new FileSystemException(uri, message); | 82 return new FileSystemException(uri, message); |
82 } | 83 } |
83 } | 84 } |
OLD | NEW |