copyTo method

  1. @override
Folder copyTo(
  1. Folder parentFolder
)
override

Copy this resource to a child of the parentFolder with the same kind and shortName as this resource. If this resource is a folder, then all of the contents of the folder will be recursively copied.

The parent folder is created if it does not already exist.

Existing files and folders will be overwritten.

Return the resource corresponding to this resource in the parent folder.

Implementation

@override
Folder copyTo(Folder parentFolder) {
  final files = directory.listSync(recursive: true);
  final newPath = p.join(parentFolder.path, p.basename(path));
  final newFolder = fileSystem.directory(newPath);

  for (final file in files) {
    if (file is! io.File) {
      continue;
    }

    final newPath = p.join(newFolder.path, p.basename(file.path));
    file.copySync(newPath);
  }

  return AnalyzerFolder(fileSystem, newFolder, provider);
}