moveVirtualToVirtual static method
Implementation
static Entity moveVirtualToVirtual({
required String filePathIn,
required String dirPathOut,
required Virtual fsIn,
required Virtual fsOut,
EntityType type = EntityType.file,
}) {
final entity = fsIn.open(filePathIn, type: type)!;
final dirOut = fsOut.open(dirPathOut, type: EntityType.dir)! as VDir;
final dirIn = fsOut.open(
dirname(filePathIn),
type: EntityType.dir,
)! as VDir;
if (dirOut.children[entity.name] == null) {
dirOut.children[entity.name] = entity;
dirIn.children.remove(entity.name);
} else {
throw "[Virtual FileSystem]: file or dir with also name exists!";
}
final path = join(dirPathOut, entity.name);
return switch (type) {
EntityType.dir => Dir(path),
EntityType.file => File(path),
};
}