copy method

Future<String> copy(
  1. String distribution,
  2. String newName
)

Copy a WSL distro by name

Implementation

Future<String> copy(String distribution, String newName) async {
  String exportPath =
      getInstancePath(distribution).file('$distribution.ext4');
  // Copy
  String exportRes = await export(distribution, exportPath);
  String importRes =
      await import(newName, getInstancePath(newName).path, exportPath);

  // Cleanup, delete file
  File file = File(exportPath);
  if (file.existsSync()) {
    file.deleteSync();
  }
  return '$exportRes $importRes';
}