| 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 analyzer.file_system.physical_file_system; | 5 library analyzer.file_system.physical_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 String readAsStringSync() { | 125 String readAsStringSync() { |
| 126 try { | 126 try { |
| 127 io.File file = _entry as io.File; | 127 io.File file = _entry as io.File; |
| 128 return FileBasedSource.fileReadMode(file.readAsStringSync()); | 128 return FileBasedSource.fileReadMode(file.readAsStringSync()); |
| 129 } on io.FileSystemException catch (exception) { | 129 } on io.FileSystemException catch (exception) { |
| 130 throw new FileSystemException(exception.path, exception.message); | 130 throw new FileSystemException(exception.path, exception.message); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 @override | 134 @override |
| 135 void writeAsBytesSync(List<int> bytes) { | |
| 136 try { | |
| 137 io.File file = _entry as io.File; | |
| 138 file.writeAsBytesSync(bytes); | |
| 139 } on io.FileSystemException catch (exception) { | |
| 140 throw new FileSystemException(exception.path, exception.message); | |
| 141 } | |
| 142 } | |
| 143 | |
| 144 @override | |
| 145 Resource renameSync(String newPath) { | 135 Resource renameSync(String newPath) { |
| 146 try { | 136 try { |
| 147 io.File file = _entry as io.File; | 137 io.File file = _entry as io.File; |
| 148 io.File newFile = file.renameSync(newPath); | 138 io.File newFile = file.renameSync(newPath); |
| 149 return new _PhysicalFile(newFile); | 139 return new _PhysicalFile(newFile); |
| 150 } on io.FileSystemException catch (exception) { | 140 } on io.FileSystemException catch (exception) { |
| 151 throw new FileSystemException(exception.path, exception.message); | 141 throw new FileSystemException(exception.path, exception.message); |
| 152 } | 142 } |
| 143 } |
| 144 |
| 145 @override |
| 146 void writeAsBytesSync(List<int> bytes) { |
| 147 try { |
| 148 io.File file = _entry as io.File; |
| 149 file.writeAsBytesSync(bytes); |
| 150 } on io.FileSystemException catch (exception) { |
| 151 throw new FileSystemException(exception.path, exception.message); |
| 152 } |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * A `dart:io` based implementation of [Folder]. | 157 * A `dart:io` based implementation of [Folder]. |
| 158 */ | 158 */ |
| 159 class _PhysicalFolder extends _PhysicalResource implements Folder { | 159 class _PhysicalFolder extends _PhysicalResource implements Folder { |
| 160 _PhysicalFolder(io.Directory directory) : super(directory); | 160 _PhysicalFolder(io.Directory directory) : super(directory); |
| 161 | 161 |
| 162 @override | 162 @override |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 bool operator ==(other) { | 251 bool operator ==(other) { |
| 252 if (runtimeType != other.runtimeType) { | 252 if (runtimeType != other.runtimeType) { |
| 253 return false; | 253 return false; |
| 254 } | 254 } |
| 255 return path == other.path; | 255 return path == other.path; |
| 256 } | 256 } |
| 257 | 257 |
| 258 @override | 258 @override |
| 259 String toString() => path; | 259 String toString() => path; |
| 260 } | 260 } |
| OLD | NEW |