move function

void move(
  1. String from,
  2. String to, {
  3. bool overwrite = false,
})

Implementation

void move(String from, String to, {bool overwrite = false}) {
  var dest = to;

  if (isDirectory(to)) {
    dest = p.join(to, p.basename(from));
  }

  if (!overwrite && exists(dest)) {
    StatusHelper.failed('The [to] path ${truepath(dest)} already exists.');
  }
  try {
    File(from).renameSync(dest);
  } on FileSystemException catch (_) {
    /// Invalid cross-device link
    /// We can't move files across a partition so
    /// do a copy/delete.
    copy(from, to, overwrite: overwrite);
    delete(from);
  }

  /// ignore: avoid_catches_without_on_clauses
  catch (e) {
    StatusHelper.failed('error: $e');
  }
}