format method
Future<void>
format(
- String type, {
- bool takeOwnership = false,
- dynamic encryptPassphrase,
- UDisksFormatEraseMethod? erase,
- bool updatePartitionType = false,
- bool noBlock = false,
- bool dryRunFirst = false,
- bool noDiscard = false,
- Iterable<
UDisksConfigurationItem> configItems = const [], - bool tearDown = false,
Formats the device with a file system, partition table or other well-known content.
Implementation
Future<void> format(String type,
{bool takeOwnership = false,
dynamic encryptPassphrase,
UDisksFormatEraseMethod? erase,
bool updatePartitionType = false,
bool noBlock = false,
bool dryRunFirst = false,
bool noDiscard = false,
Iterable<UDisksConfigurationItem> configItems = const [],
bool tearDown = false}) async {
var options = <String, DBusValue>{};
if (takeOwnership) {
options['take-ownership'] = DBusBoolean(true);
}
if (encryptPassphrase != null) {
if (encryptPassphrase is String) {
options['encrypt.passphrase'] = DBusString(encryptPassphrase);
} else if (encryptPassphrase is List<int>) {
options['encrypt.passphrase'] = DBusArray.byte(encryptPassphrase);
} else {
throw FormatException('encryptPassphrase must be String or List<int>');
}
}
if (erase != null) {
String value;
switch (erase) {
case UDisksFormatEraseMethod.zero:
value = 'zero';
break;
case UDisksFormatEraseMethod.ataSecureErase:
value = 'ata-secure-erase';
break;
case UDisksFormatEraseMethod.ataSecureEraseEnhanced:
value = 'ata-secure-erase-enhanced';
break;
}
options['erase'] = DBusString(value);
}
if (updatePartitionType) {
options['update-partition-type'] = DBusBoolean(true);
}
if (noBlock) {
options['no-block'] = DBusBoolean(true);
}
if (dryRunFirst) {
options['dry-run-first'] = DBusBoolean(true);
}
if (noDiscard) {
options['no-discard'] = DBusBoolean(true);
}
if (configItems.isNotEmpty) {
options['config-items'] = DBusArray(DBusSignature('(sa{sv})'),
configItems.map((item) => _encodeConfigurationItem(item)));
}
if (tearDown) {
options['tear-down'] = DBusBoolean(true);
}
await _object.callMethod(_blockInterfaceName, 'Format',
[DBusString(type), DBusDict.stringVariant(options)],
replySignature: DBusSignature(''));
}