'change permissions to the given mode. If mode is an
integer it directly encodes the os-specific modes.
if rec is True perform recursively.'

def chmod(self, mode, rec=0):

    if (not isinstance(mode, int)):
        raise TypeError(('mode    %r    must    be    an    integer' % (mode,)))
    if rec:
        for x in self.visit(rec=rec):
            py.error.checked_call(os.chmod, str(x), mode)
    py.error.checked_call(os.chmod, self.strpath, mode)
