extract clone_regular_file function