generalize file copy