Source code for reflink.reflink

# -*- coding: utf-8 -*-

"""Main module."""

import os

from . import backend





[docs]def supported_at(path): """ Returns ``True`` when a path on the filesystem supports reflinking, ``False`` otherwise. Please note that the current implementation verifies this by testing whether it's possible to reflink. """ # Currently, there's no systemcall that tests whether a point in the VFS is supported or not. # We create a file at ``path``, and clone it. a = os.path.join(path, "i_hope_no_one_will_ever_try_this_name.txt") b = os.path.join(path, "i_hope_no_one_will_ever_try_that_name.txt") with open(a, 'w+') as f: f.write(u"abc") try: reflink(a, b) return True except: pass # TODO: there are probably specific exception that we can handle finally: os.unlink(a) if os.path.isfile(b): os.unlink(b) return False