Index: pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2821268b7b303ac111567bacf87dd4ab09200415 |
--- /dev/null |
+++ b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
@@ -0,0 +1,33 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'package:analyzer/file_system/file_system.dart'; |
+import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
+ |
+/** |
+ * [ByteStore] that stores values as [File]s. |
Paul Berry
2016/10/23 10:39:19
Should this class implement some sort of LRU polic
scheglov
2016/10/23 20:54:34
Yes, we should.
I'm adding TODO.
|
+ */ |
+class FileByteStore implements ByteStore { |
+ final Folder folder; |
+ |
+ FileByteStore(this.folder); |
+ |
+ @override |
+ List<int> get(String key) { |
+ try { |
+ File file = folder.getChildAssumingFile(key); |
+ return file.readAsBytesSync(); |
+ } catch (_) { |
+ return null; |
+ } |
+ } |
+ |
+ @override |
+ void put(String key, List<int> bytes) { |
+ try { |
+ File file = folder.getChildAssumingFile(key); |
+ file.writeAsBytesSync(bytes); |
+ } catch (_) {} |
+ } |
+} |