OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import 'package:analyzer/file_system/file_system.dart'; | |
6 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | |
7 | |
8 /** | |
9 * [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.
| |
10 */ | |
11 class FileByteStore implements ByteStore { | |
12 final Folder folder; | |
13 | |
14 FileByteStore(this.folder); | |
15 | |
16 @override | |
17 List<int> get(String key) { | |
18 try { | |
19 File file = folder.getChildAssumingFile(key); | |
20 return file.readAsBytesSync(); | |
21 } catch (_) { | |
22 return null; | |
23 } | |
24 } | |
25 | |
26 @override | |
27 void put(String key, List<int> bytes) { | |
28 try { | |
29 File file = folder.getChildAssumingFile(key); | |
30 file.writeAsBytesSync(bytes); | |
31 } catch (_) {} | |
32 } | |
33 } | |
OLD | NEW |