| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 physical_file_system; | 5 library 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 'package:analyzer/src/generated/java_io.dart'; | 10 import 'package:analyzer/src/generated/java_io.dart'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 */ | 73 */ |
| 74 class _PhysicalFile extends _PhysicalResource implements File { | 74 class _PhysicalFile extends _PhysicalResource implements File { |
| 75 _PhysicalFile(io.File file) : super(file); | 75 _PhysicalFile(io.File file) : super(file); |
| 76 | 76 |
| 77 @override | 77 @override |
| 78 int get modificationStamp { | 78 int get modificationStamp { |
| 79 try { | 79 try { |
| 80 io.File file = _entry as io.File; | 80 io.File file = _entry as io.File; |
| 81 return file.lastModifiedSync().millisecondsSinceEpoch; | 81 return file.lastModifiedSync().millisecondsSinceEpoch; |
| 82 } on io.FileSystemException catch (exception) { | 82 } on io.FileSystemException catch (exception) { |
| 83 throw new FileSystemException(path, exception.message); | 83 throw new FileSystemException(exception.path, exception.message); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 @override | 87 @override |
| 88 Source createSource([Uri uri]) { | 88 Source createSource([Uri uri]) { |
| 89 io.File file = _entry as io.File; | 89 io.File file = _entry as io.File; |
| 90 JavaFile javaFile = new JavaFile(file.absolute.path); | 90 JavaFile javaFile = new JavaFile(file.absolute.path); |
| 91 if (uri == null) { | 91 if (uri == null) { |
| 92 uri = javaFile.toURI(); | 92 uri = javaFile.toURI(); |
| 93 } | 93 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 @override | 128 @override |
| 129 _PhysicalFolder getChildAssumingFolder(String relPath) { | 129 _PhysicalFolder getChildAssumingFolder(String relPath) { |
| 130 String canonicalPath = canonicalizePath(relPath); | 130 String canonicalPath = canonicalizePath(relPath); |
| 131 io.Directory directory = new io.Directory(canonicalPath); | 131 io.Directory directory = new io.Directory(canonicalPath); |
| 132 return new _PhysicalFolder(directory); | 132 return new _PhysicalFolder(directory); |
| 133 } | 133 } |
| 134 | 134 |
| 135 @override | 135 @override |
| 136 List<Resource> getChildren() { | 136 List<Resource> getChildren() { |
| 137 List<Resource> children = <Resource>[]; | 137 try { |
| 138 io.Directory directory = _entry as io.Directory; | 138 List<Resource> children = <Resource>[]; |
| 139 List<io.FileSystemEntity> entries = directory.listSync(recursive: false); | 139 io.Directory directory = _entry as io.Directory; |
| 140 int numEntries = entries.length; | 140 List<io.FileSystemEntity> entries = directory.listSync(recursive: false); |
| 141 for (int i = 0; i < numEntries; i++) { | 141 int numEntries = entries.length; |
| 142 io.FileSystemEntity entity = entries[i]; | 142 for (int i = 0; i < numEntries; i++) { |
| 143 if (entity is io.Directory) { | 143 io.FileSystemEntity entity = entries[i]; |
| 144 children.add(new _PhysicalFolder(entity)); | 144 if (entity is io.Directory) { |
| 145 } else if (entity is io.File) { | 145 children.add(new _PhysicalFolder(entity)); |
| 146 children.add(new _PhysicalFile(entity)); | 146 } else if (entity is io.File) { |
| 147 children.add(new _PhysicalFile(entity)); |
| 148 } |
| 147 } | 149 } |
| 150 return children; |
| 151 } on io.FileSystemException catch (exception) { |
| 152 throw new FileSystemException(exception.path, exception.message); |
| 148 } | 153 } |
| 149 return children; | |
| 150 } | 154 } |
| 151 | 155 |
| 152 @override | 156 @override |
| 153 bool isOrContains(String path) { | 157 bool isOrContains(String path) { |
| 154 if (path == this.path) { | 158 if (path == this.path) { |
| 155 return true; | 159 return true; |
| 156 } | 160 } |
| 157 return contains(path); | 161 return contains(path); |
| 158 } | 162 } |
| 159 } | 163 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bool operator ==(other) { | 195 bool operator ==(other) { |
| 192 if (runtimeType != other.runtimeType) { | 196 if (runtimeType != other.runtimeType) { |
| 193 return false; | 197 return false; |
| 194 } | 198 } |
| 195 return path == other.path; | 199 return path == other.path; |
| 196 } | 200 } |
| 197 | 201 |
| 198 @override | 202 @override |
| 199 String toString() => path; | 203 String toString() => path; |
| 200 } | 204 } |
| OLD | NEW |