Exemplo n.º 1
0
def recursive_dirlist(paths, xdev, bup_dir=None,
                      excluded_paths=None,
                      exclude_rxs=None,
                      xdev_exceptions=frozenset()):
    with finalized_fd(b'.') as startdir:
        try:
            assert not isinstance(paths, str)
            for path in paths:
                try:
                    pst = xstat.lstat(path)
                    if stat.S_ISLNK(pst.st_mode):
                        yield (path, pst)
                        continue
                except OSError as e:
                    add_error('recursive_dirlist: %s' % e)
                    continue
                try:
                    opened_pfile = finalized_fd(path)
                except OSError as e:
                    add_error(e)
                    continue
                with opened_pfile as pfile:
                    pst = xstat.fstat(pfile)
                    if xdev:
                        xdev = pst.st_dev
                    else:
                        xdev = None
                    if stat.S_ISDIR(pst.st_mode):
                        os.fchdir(pfile)
                        prepend = os.path.join(path, b'')
                        for i in _recursive_dirlist(prepend=prepend, xdev=xdev,
                                                    bup_dir=bup_dir,
                                                    excluded_paths=excluded_paths,
                                                    exclude_rxs=exclude_rxs,
                                                    xdev_exceptions=xdev_exceptions):
                            yield i
                        os.fchdir(startdir)
                    else:
                        prepend = path
                yield (prepend,pst)
        except:
            try:
                os.fchdir(startdir)
            except:
                pass
            raise
Exemplo n.º 2
0
 def stat(self):
     return xstat.fstat(self.fd)
Exemplo n.º 3
0
 def stat(self):
     return xstat.fstat(self.fd)