pathutils.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:karton 作者: karton 项目源码 文件源码
def hard_link_or_copy(src, dst):
    '''
    Create a hard link from `src` to `dst` if possible. Otherwise copy `src` to `dst`.

    src:
        The source file or directory.
    dst:
        The destination.
    '''
    try:
        os.link(src, dst)
    except OSError as exc:
        if exc.errno in (errno.EXDEV, errno.EPERM):
            # Cannot create the hard link, maybe src is a directory or src and dst are on
            # different devices, so we cannot link.
            verbose('Failed to link from "%s" to "%s" as they are not different devices. '
                    'Copying instead.' %
                    (src, dst))
            copy_path(src, dst)
        else:
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号