Copy path to target. If mode is True, will copy permission from path to target. If stat is True, copy permission, last modification time, last access time, and flags from path to target.
(self, target, mode=False, stat=False)
| 832 | return self.stat().mtime |
| 833 | |
| 834 | def copy(self, target, mode=False, stat=False): |
| 835 | class="st">"""Copy path to target. |
| 836 | |
| 837 | If mode is True, will copy permission from path to target. |
| 838 | If stat is True, copy permission, last modification |
| 839 | time, last access time, and flags from path to target. |
| 840 | class="st">""" |
| 841 | if self.check(file=1): |
| 842 | if target.check(dir=1): |
| 843 | target = target.join(self.basename) |
| 844 | assert self != target |
| 845 | copychunked(self, target) |
| 846 | if mode: |
| 847 | copymode(self.strpath, target.strpath) |
| 848 | if stat: |
| 849 | copystat(self, target) |
| 850 | else: |
| 851 | |
| 852 | def rec(p): |
| 853 | return p.check(link=0) |
| 854 | |
| 855 | for x in self.visit(rec=rec): |
| 856 | relpath = x.relto(self) |
| 857 | newx = target.join(relpath) |
| 858 | newx.dirpath().ensure(dir=1) |
| 859 | if x.check(link=1): |
| 860 | newx.mksymlinkto(x.readlink()) |
| 861 | continue |
| 862 | elif x.check(file=1): |
| 863 | copychunked(x, newx) |
| 864 | elif x.check(dir=1): |
| 865 | newx.ensure(dir=1) |
| 866 | if mode: |
| 867 | copymode(x.strpath, newx.strpath) |
| 868 | if stat: |
| 869 | copystat(x, newx) |
| 870 | |
| 871 | def rename(self, target): |
| 872 | class="st">""class="st">"Rename this path to target."class="st">"" |