| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:power_management/power_management.dart' as power_management; | 9 import 'package:power_management/power_management.dart' as power_management; |
| 10 import 'package:sdk_services/sdk_services.dart'; | 10 import 'package:sdk_services/sdk_services.dart'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 /// and insert the SD card and through diffing the content of '/dev' the | 39 /// and insert the SD card and through diffing the content of '/dev' the |
| 40 /// device name for the card is determined. | 40 /// device name for the card is determined. |
| 41 Future<String> findSDCard() async { | 41 Future<String> findSDCard() async { |
| 42 await ctx.readLine( | 42 await ctx.readLine( |
| 43 'Please remove all SD cards from this computer. Then press Enter.'); | 43 'Please remove all SD cards from this computer. Then press Enter.'); |
| 44 Set defaultDisks = new Set.from(await listPossibleSDCards()); | 44 Set defaultDisks = new Set.from(await listPossibleSDCards()); |
| 45 ctx.log('Default disks $defaultDisks'); | 45 ctx.log('Default disks $defaultDisks'); |
| 46 | 46 |
| 47 // Wait for an additional disk. | 47 // Wait for an additional disk. |
| 48 await ctx.readLine( | 48 await ctx.readLine( |
| 49 'Please insert the SD card you want to use with Fletch. ' | 49 'Please insert the SD card you want to use with Dartino. ' |
| 50 'Then press Enter.'); | 50 'Then press Enter.'); |
| 51 int retryCount = 10; | 51 int retryCount = 10; |
| 52 while (true) { | 52 while (true) { |
| 53 Set disks = new Set.from(await listPossibleSDCards()); | 53 Set disks = new Set.from(await listPossibleSDCards()); |
| 54 ctx.log('Disks $disks'); | 54 ctx.log('Disks $disks'); |
| 55 Set diff = disks.difference(defaultDisks); | 55 Set diff = disks.difference(defaultDisks); |
| 56 if (diff.length == 1) { | 56 if (diff.length == 1) { |
| 57 return diff.first; | 57 return diff.first; |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 var mountDir = await (await ctx.tmpDir).createTemp(); | 360 var mountDir = await (await ctx.tmpDir).createTemp(); |
| 361 // Explicitly mount the first partition which is the boot partition. | 361 // Explicitly mount the first partition which is the boot partition. |
| 362 var partition = device.startsWith('mmcblk') ? '${device}p1' : '${device}1'; | 362 var partition = device.startsWith('mmcblk') ? '${device}p1' : '${device}1'; |
| 363 var result = await ctx.runProcess('mount', [partition, mountDir.path]); | 363 var result = await ctx.runProcess('mount', [partition, mountDir.path]); |
| 364 if (result.exitCode != 0) { | 364 if (result.exitCode != 0) { |
| 365 await ctx.failure('Failed to mount $device', result.stderr); | 365 await ctx.failure('Failed to mount $device', result.stderr); |
| 366 } | 366 } |
| 367 return mountDir; | 367 return mountDir; |
| 368 } | 368 } |
| 369 } | 369 } |
| OLD | NEW |