##// END OF EJS Templates
copyfile: add an optional parameter to copy other stat data...
Siddharth Agarwal -
r27369:c48ecc0b stable
parent child Browse files
Show More
@@ -806,8 +806,9 b' def checksignature(func):'
806 806
807 807 return check
808 808
809 def copyfile(src, dest, hardlink=False):
810 "copy a file, preserving mode and atime/mtime"
809 def copyfile(src, dest, hardlink=False, copystat=False):
810 '''copy a file, preserving mode and optionally other stat info like
811 atime/mtime'''
811 812 if os.path.lexists(dest):
812 813 unlink(dest)
813 814 # hardlinks are problematic on CIFS, quietly ignore this flag
@@ -820,9 +821,15 b' def copyfile(src, dest, hardlink=False):'
820 821 pass # fall back to normal copy
821 822 if os.path.islink(src):
822 823 os.symlink(os.readlink(src), dest)
824 # copytime is ignored for symlinks, but in general copytime isn't needed
825 # for them anyway
823 826 else:
824 827 try:
825 828 shutil.copyfile(src, dest)
829 if copystat:
830 # copystat also copies mode
831 shutil.copystat(src, dest)
832 else:
826 833 shutil.copymode(src, dest)
827 834 except shutil.Error as inst:
828 835 raise Abort(str(inst))
General Comments 0
You need to be logged in to leave comments. Login now