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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/store/split_store.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/index/store/separate_file_manager.dart
diff --git a/pkg/analysis_server/lib/src/index/store/separate_file_manager.dart b/pkg/analysis_server/lib/src/index/store/separate_file_manager.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1644ae787d2212c8fce869ffcaea553dbef00f39
--- /dev/null
+++ b/pkg/analysis_server/lib/src/index/store/separate_file_manager.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2014, 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.
+
+library index.store.separate_file_mananer;
+
+import 'dart:async';
+import 'dart:io';
+import 'dart:typed_data';
+
+import 'package:analysis_server/src/index/store/split_store.dart';
+import 'package:path/path.dart' as pathos;
+
+
+/**
+ * An implementation of [FileManager] that keeps each file in a separate file
+ * system file.
+ */
+class SeparateFileManager implements FileManager {
+ final Directory _base;
+
+ SeparateFileManager(this._base) {
+ clear();
+ }
+
+ @override
+ void clear() {
+ List<FileSystemEntity> entries = _base.listSync();
+ for (FileSystemEntity entry in entries) {
+ entry.deleteSync(recursive: true);
+ }
+ }
+
+ @override
+ void delete(String name) {
+ File file = _getFile(name);
+ if (file.existsSync()) {
+ 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.
+ }
+ }
+
+ @override
+ Future<List<int>> read(String name) {
+ File file = _getFile(name);
+ return file.exists().then((bool exists) {
+ if (!exists) {
+ return null;
+ }
+ 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.
+ });
+ }
+
+ @override
+ Future write(String name, List<int> bytes) {
+ return _getFile(name).writeAsBytes(bytes);
+ }
+
+ File _getFile(String name) {
+ String path = pathos.join(_base.path, name);
+ return new File(path);
+ }
+}
« 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