| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "dart:io"; | 5 import "dart:io"; |
| 6 | 6 |
| 7 const sampleText = "Sample text file."; | 7 const sampleText = "Sample text file."; |
| 8 | 8 |
| 9 main() async { | 9 main() async { |
| 10 var file = await createFile(); | 10 var file = await createFile(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 var tempDir = await Directory.systemTemp.createTemp("sample"); | 50 var tempDir = await Directory.systemTemp.createTemp("sample"); |
| 51 var filePath = tempDir.path + Platform.pathSeparator + "sample.txt"; | 51 var filePath = tempDir.path + Platform.pathSeparator + "sample.txt"; |
| 52 var file = new File(filePath); | 52 var file = new File(filePath); |
| 53 await file.create(); | 53 await file.create(); |
| 54 await file.writeAsString(sampleText); | 54 await file.writeAsString(sampleText); |
| 55 return file; | 55 return file; |
| 56 } | 56 } |
| 57 | 57 |
| 58 deleteFile(File file) async { | 58 deleteFile(File file) async { |
| 59 // Removes the file and the temporary directory it's in. | 59 // Removes the file and the temporary directory it's in. |
| 60 var parentDir = new Directory(file.path.substring(0, | 60 var parentDir = new Directory( |
| 61 file.path.lastIndexOf(Platform.pathSeparator))); | 61 file.path.substring(0, file.path.lastIndexOf(Platform.pathSeparator))); |
| 62 await parentDir.delete(recursive: true); | 62 await parentDir.delete(recursive: true); |
| 63 } | 63 } |
| OLD | NEW |