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

Side by Side Diff: pkg/analysis_server/lib/src/index/store/separate_file_manager.dart

Issue 346273005: A FileManager implementation to keep each index file in a separate file system file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/store/split_store.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library index.store.separate_file_mananer;
6
7 import 'dart:async';
8 import 'dart:io';
9 import 'dart:typed_data';
10
11 import 'package:analysis_server/src/index/store/split_store.dart';
12 import 'package:path/path.dart' as pathos;
13
14
15 /**
16 * An implementation of [FileManager] that keeps each file in a separate file
17 * system file.
18 */
19 class SeparateFileManager implements FileManager {
20 final Directory _base;
21
22 SeparateFileManager(this._base) {
23 clear();
24 }
25
26 @override
27 void clear() {
28 List<FileSystemEntity> entries = _base.listSync();
29 for (FileSystemEntity entry in entries) {
30 entry.deleteSync(recursive: true);
31 }
32 }
33
34 @override
35 void delete(String name) {
36 File file = _getFile(name);
37 if (file.existsSync()) {
38 file.deleteSync();
Brian Wilkerson 2014/06/23 19:52:32 Is it a problem to call deleteSync for a file that
scheglov 2014/06/23 20:00:22 Done.
39 }
40 }
41
42 @override
43 Future<List<int>> read(String name) {
44 File file = _getFile(name);
45 return file.exists().then((bool exists) {
46 if (!exists) {
47 return null;
48 }
49 return file.readAsBytes();
Brian Wilkerson 2014/06/23 19:52:32 Similar question. If readAsBytes throws an excepti
scheglov 2014/06/23 20:00:22 Done.
50 });
51 }
52
53 @override
54 Future write(String name, List<int> bytes) {
55 return _getFile(name).writeAsBytes(bytes);
56 }
57
58 File _getFile(String name) {
59 String path = pathos.join(_base.path, name);
60 return new File(path);
61 }
62 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/store/split_store.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698