def copy(self, other):
"""Copy self to other. Also copies data. Other must be Path"""
if self.isreg():
other.writefileobj(self.open("rb"))
elif self.isdir():
os.mkdir(other.name)
elif self.issym():
os.symlink(self.symtext, other.name)
os.lchown(other.name, self.stat.st_uid, self.stat.st_gid)
other.setdata()
return # no need to copy symlink attributes
elif self.isfifo():
os.mkfifo(other.name)
elif self.issock():
socket.socket(socket.AF_UNIX).bind(other.name)
elif self.isdev():
if self.type == "chr":
devtype = "c"
else:
devtype = "b"
other.makedev(devtype, *self.devnums)
self.copy_attribs(other)
评论列表
文章目录