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

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

Issue 2864183002: Throw FileSystemException from FileSystemEntity methods. (Closed)
Patch Set: 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
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.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';
(...skipping 25 matching lines...) Expand all
36 _PhysicalFileSystemEntity(this.uri); 36 _PhysicalFileSystemEntity(this.uri);
37 37
38 @override 38 @override
39 int get hashCode => uri.hashCode; 39 int get hashCode => uri.hashCode;
40 40
41 @override 41 @override
42 bool operator ==(Object other) => 42 bool operator ==(Object other) =>
43 other is _PhysicalFileSystemEntity && other.uri == uri; 43 other is _PhysicalFileSystemEntity && other.uri == uri;
44 44
45 @override 45 @override
46 Future<List<int>> readAsBytes() => new io.File.fromUri(uri).readAsBytes();
47
48 @override
49 Future<String> readAsString() => new io.File.fromUri(uri).readAsString();
50
51 @override
52 Future<bool> exists() async { 46 Future<bool> exists() async {
53 if (await io.FileSystemEntity.isFile(uri.toFilePath())) { 47 if (await io.FileSystemEntity.isFile(uri.toFilePath())) {
54 return new io.File.fromUri(uri).exists(); 48 return new io.File.fromUri(uri).exists();
55 } else { 49 } else {
56 return new io.Directory.fromUri(uri).exists(); 50 return new io.Directory.fromUri(uri).exists();
57 } 51 }
58 } 52 }
59 53
60 @override 54 @override
61 Future<DateTime> lastModified() => new io.File.fromUri(uri).lastModified(); 55 Future<DateTime> lastModified() async {
56 try {
57 return await new io.File.fromUri(uri).lastModified();
58 } on io.FileSystemException catch (exception) {
59 throw new FileSystemException(uri, exception.message);
Paul Berry 2017/05/07 14:06:49 The logic you're removing from pkg/front_end/lib/s
scheglov 2017/05/07 15:55:25 Done.
60 }
61 }
62
63 @override
64 Future<List<int>> readAsBytes() async {
65 try {
66 return await new io.File.fromUri(uri).readAsBytes();
67 } on io.FileSystemException catch (exception) {
68 throw new FileSystemException(uri, exception.message);
69 }
70 }
71
72 @override
73 Future<String> readAsString() async {
74 try {
75 return await new io.File.fromUri(uri).readAsString();
76 } on io.FileSystemException catch (exception) {
77 throw new FileSystemException(uri, exception.message);
78 }
79 }
62 } 80 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/memory_file_system.dart ('k') | pkg/front_end/lib/src/fasta/source/source_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698