copyFileContent function

Future<int> copyFileContent(
  1. File src,
  2. File dst
)

Copy the file content

Implementation

Future<int> copyFileContent(File src, File dst) async {
  try {
    await src.copy(dst.path);
  } catch (_) {
    final parent = dst.parent;
    if (!await parent.exists()) {
      await parent.create(recursive: true);
    }
    await src.copy(dst.path);
  }
  /*
  var inStream = src.openRead();
  devPrint('openWrite1');
  var outSink = dst.openWrite();
  devPrint('openWrite2');
  try {
    await inStream.cast<List<int>>().pipe(outSink);
    devPrint('openWrite3');
  } catch (_) {
    devPrint('openWrite4');
    final parent = dst.parent;
    devPrint('openWrite5');
    if (!await parent.exists()) {
      await parent.create(recursive: true);
    }
    devPrint('openWrite6');
    outSink = dst.openWrite();
    inStream = src.openRead();
    await inStream.cast<List<int>>().pipe(outSink);
  }
  // Copy mode for unix executables
   */
  return 1;
}