copyDirectory method

Future<void> copyDirectory(
  1. Directory to
)

Implementation

Future<void> copyDirectory(Directory to) async {
  if (!to.existsSync()) {
    to.createSync(recursive: true);
  }

  for (var entity in this.listSync(recursive: true)) {
    if (entity is Directory) {
    } else if (entity is File) {
      var filePath = p.join(
        to.path,
        p.relative(entity.path, from: this.path),
      );
      var file = File(filePath);
      if (!file.parent.existsSync()) {
        file.parent.createSync(recursive: true);
      }
      entity.copySync(file.path);
    }
  }
}