copyfile and type functions