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

Unified Diff: pkg/analyzer/lib/file_system/physical_file_system.dart

Issue 1811643002: Add File.readAsBytesSync/writeAsBytesSync() methods. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/file_system/physical_file_system.dart
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index cdfa9a6f4e5efaa656029ec8501158c1e4b27d12..1a4e7939296aba1a74a535b01c0e8dc4008f6bc3 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -19,8 +19,8 @@ import 'package:watcher/watcher.dart';
* A `dart:io` based implementation of [ResourceProvider].
*/
class PhysicalResourceProvider implements ResourceProvider {
- static final NORMALIZE_EOL_ALWAYS = (String string) =>
- string.replaceAll(new RegExp('\r\n?'), '\n');
+ static final NORMALIZE_EOL_ALWAYS =
+ (String string) => string.replaceAll(new RegExp('\r\n?'), '\n');
static final PhysicalResourceProvider INSTANCE =
new PhysicalResourceProvider(null);
@@ -112,6 +112,16 @@ class _PhysicalFile extends _PhysicalResource implements File {
}
@override
+ List<int> readAsBytesSync() {
+ try {
+ io.File file = _entry as io.File;
+ return file.readAsBytesSync();
+ } on io.FileSystemException catch (exception) {
+ throw new FileSystemException(exception.path, exception.message);
+ }
+ }
+
+ @override
String readAsStringSync() {
try {
io.File file = _entry as io.File;
@@ -120,6 +130,16 @@ class _PhysicalFile extends _PhysicalResource implements File {
throw new FileSystemException(exception.path, exception.message);
}
}
+
+ @override
+ void writeAsBytesSync(List<int> bytes) {
+ try {
+ io.File file = _entry as io.File;
+ file.writeAsBytesSync(bytes);
+ } on io.FileSystemException catch (exception) {
+ throw new FileSystemException(exception.path, exception.message);
+ }
+ }
}
/**
« no previous file with comments | « pkg/analyzer/lib/file_system/memory_file_system.dart ('k') | pkg/analyzer/test/file_system/memory_file_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698