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

Unified Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 2120473004: Reimplement devfs in dart. Implementation now writes to disk. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code review Created 4 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 | runtime/observatory/tests/service/dev_fs_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/vmservice_io.dart
diff --git a/runtime/bin/vmservice/vmservice_io.dart b/runtime/bin/vmservice/vmservice_io.dart
index bfa99a6830d99593cf705f3fc68d2d66e5419509..ba2b27701501b054cd2d156bc63c45886bd8d9b4 100644
--- a/runtime/bin/vmservice/vmservice_io.dart
+++ b/runtime/bin/vmservice/vmservice_io.dart
@@ -60,6 +60,45 @@ Future cleanupCallback() async {
_shutdown();
}
+Future<Uri> createTempDirCallback(String base) async {
+ Directory temp = await Directory.systemTemp.createTemp(base);
+ return temp.uri;
+}
+
+Future deleteDirCallback(Uri path) async {
+ Directory dir = new Directory.fromUri(path);
+ await dir.delete(recursive: true);
+}
+
+Future writeFileCallback(Uri path, List<int> bytes) async {
+ var file = await new File.fromUri(path);
+ await file.writeAsBytes(bytes);
+}
+
+Future<List<int>> readFileCallback(Uri path) async {
+ var file = await new File.fromUri(path);
+ return await file.readAsBytes();
+}
+
+Future<List<Map<String,String>>> listFilesCallback(Uri dirPath) async {
+ var dir = new Directory.fromUri(dirPath);
+ var dirPathStr = dirPath.path;
+ var stream = dir.list(recursive: true);
+ var result = [];
+ await for (var fileEntity in stream) {
+ var stat = await fileEntity.stat();
+ if (stat.type == FileSystemEntityType.FILE &&
+ fileEntity.path.startsWith(dirPathStr)) {
+ var map = {};
+ map['name'] = '/' + fileEntity.path.substring(dirPathStr.length);
+ map['size'] = stat.size;
+ map['modified'] = stat.modified.millisecondsSinceEpoch;
+ result.add(map);
+ }
+ }
+ return result;
+}
+
_clearFuture(_) {
serverFuture = null;
}
@@ -96,6 +135,11 @@ _registerSignalHandler() {
main() {
// Set embedder hooks.
VMServiceEmbedderHooks.cleanup = cleanupCallback;
+ VMServiceEmbedderHooks.createTempDir = createTempDirCallback;
+ VMServiceEmbedderHooks.deleteDir = deleteDirCallback;
+ VMServiceEmbedderHooks.writeFile = writeFileCallback;
+ VMServiceEmbedderHooks.readFile = readFileCallback;
+ VMServiceEmbedderHooks.listFiles = listFilesCallback;
// Always instantiate the vmservice object so that the exit message
// can be delivered and waiting loaders can be cancelled.
var service = new VMService();
« no previous file with comments | « no previous file | runtime/observatory/tests/service/dev_fs_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698