copyVirtualToVirtual static method

File copyVirtualToVirtual(
  1. {required String filePathIn,
  2. required String dirPathOut,
  3. required Virtual fsIn,
  4. required Virtual fsOut}
)

Implementation

static File copyVirtualToVirtual({
  required String filePathIn,
  required String dirPathOut,
  required Virtual fsIn,
  required Virtual fsOut,
}) {
  final file = fsIn.open(filePathIn)! as VFile;
  final dir = fsOut.open(dirPathOut)! as VDir;

  if (dir.children[file.name] == null) {
    dir.children[file.name] = VFile.clone(file);
  } else {
    throw "[Virtual FileSystem]: file or dir with also name exists!";
  }

  return File(join(dirPathOut, file.name));
}