copy static method

void copy(
  1. String source,
  2. String destination
)

Copies a file.

Implementation

static void copy(String source, String destination) {
  try {
    final srcFile = File(source);
    if (!srcFile.existsSync()) {
      throw DeepLinkException('Source file does not exist: $source');
    }
    final destDir = Directory(PathUtils.dirname(destination));
    if (!destDir.existsSync()) {
      destDir.createSync(recursive: true);
    }
    srcFile.copySync(destination);
  } catch (e) {
    if (e is DeepLinkException) rethrow;
    throw DeepLinkException('Failed to copy file from $source to $destination', e);
  }
}