OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library vmservice_io; | 5 library vmservice_io; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Directory temp = await Directory.systemTemp.createTemp(base); | 65 Directory temp = await Directory.systemTemp.createTemp(base); |
66 return temp.uri; | 66 return temp.uri; |
67 } | 67 } |
68 | 68 |
69 Future deleteDirCallback(Uri path) async { | 69 Future deleteDirCallback(Uri path) async { |
70 Directory dir = new Directory.fromUri(path); | 70 Directory dir = new Directory.fromUri(path); |
71 await dir.delete(recursive: true); | 71 await dir.delete(recursive: true); |
72 } | 72 } |
73 | 73 |
74 Future writeFileCallback(Uri path, List<int> bytes) async { | 74 Future writeFileCallback(Uri path, List<int> bytes) async { |
75 var file = await new File.fromUri(path); | 75 var file = new File.fromUri(path); |
| 76 var parent_directory = file.parent; |
| 77 await parent_directory.create(recursive: true); |
76 await file.writeAsBytes(bytes); | 78 await file.writeAsBytes(bytes); |
77 } | 79 } |
78 | 80 |
79 Future<List<int>> readFileCallback(Uri path) async { | 81 Future<List<int>> readFileCallback(Uri path) async { |
80 var file = await new File.fromUri(path); | 82 var file = new File.fromUri(path); |
81 return await file.readAsBytes(); | 83 return await file.readAsBytes(); |
82 } | 84 } |
83 | 85 |
84 Future<List<Map<String,String>>> listFilesCallback(Uri dirPath) async { | 86 Future<List<Map<String,String>>> listFilesCallback(Uri dirPath) async { |
85 var dir = new Directory.fromUri(dirPath); | 87 var dir = new Directory.fromUri(dirPath); |
86 var dirPathStr = dirPath.path; | 88 var dirPathStr = dirPath.path; |
87 var stream = dir.list(recursive: true); | 89 var stream = dir.list(recursive: true); |
88 var result = []; | 90 var result = []; |
89 await for (var fileEntity in stream) { | 91 await for (var fileEntity in stream) { |
90 var filePath = new Uri.file(fileEntity.path).path; | 92 var filePath = new Uri.file(fileEntity.path).path; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 Timer.run(() {}); | 155 Timer.run(() {}); |
154 } | 156 } |
155 scriptLoadPort.handler = _processLoadRequest; | 157 scriptLoadPort.handler = _processLoadRequest; |
156 // Register signal handler after a small delay to avoid stalling main | 158 // Register signal handler after a small delay to avoid stalling main |
157 // isolate startup. | 159 // isolate startup. |
158 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler); | 160 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler); |
159 return scriptLoadPort; | 161 return scriptLoadPort; |
160 } | 162 } |
161 | 163 |
162 _shutdown() native "VMServiceIO_Shutdown"; | 164 _shutdown() native "VMServiceIO_Shutdown"; |
OLD | NEW |