Utility method that yields all directories on the device's file
            systems.
322715
def list_all_directories(self):
        
        def list_dirs_recursively(directory):
            if directory == self.filesystem:
                yield directory
            d_gen = itertools.chain(
                directory.directories,
                *tuple(list_dirs_recursively(d)
                       for d in directory.directories))
            for d in d_gen:
                yield d
        return list_dirs_recursively(self.filesystem)
1257930
def get_files():
    

    files_root = path.join(path.dirname(__file__), 'files')

    for root, dirs, files in walk(files_root):
        rel_root = path.relpath(root, files_root)

        for file_name in files:
            try:
                f = open(path.join(root, file_name), 'r', encoding='utf-8')
                with f:
                    yield rel_root, file_name, f.read(), True
            except UnicodeError:
                f = open(path.join(root, file_name), 'rb')
                with f:
                    yield rel_root, file_name, f.read(), False
779902
def files_in_dir(path, extension):
    """"""
    ends = '.{0}'.format(extension)
    return (f for f in os.listdir(path) if f.endswith(ends))
464609
def dir_path(dir):
    """"""
    old_dir = os.getcwd()
    os.chdir(dir)
    yield
    os.chdir(old_dir)
1118215
def output_files(self):
        
        for item in self.source_files:
            yield os.path.join(self.address.repo, self.address.path, item)
395873
def get_files(directory, recursive=False):
    """"""
    files_out = []
    if recursive:
        for root, dirs, files in os.walk(os.path.abspath(directory)):
            files = [os.path.join(root, f) for f in files]
            files_out.append(files)
        files_out = list(itertools.chain(*files_out))
    else:
        files_out = [os.path.join(directory, f) for f in os.listdir(directory)]
        files_out = list(filter(lambda f: os.path.isfile(f), files_out))

    # order alphabetically on file name
    return sorted(files_out)
806834
def finddirs(root):
    """"""
    retval = []
    for root, dirs, files in os.walk(root):
        for d in dirs:
            retval.append(os.path.join(root, d))
    return retval
801673
def find_files_for_use(self, all_files):
        
        for path in all_files:
            # Find the path relative to the parent dir
            relpath = self.relpath_for(path)

            # Don't care about the ./
            if relpath.startswith("./"):
                relpath = relpath[2:]

            # Only care about paths that aren't filtered
            if not self.is_filtered(relpath):
                yield Path(path, relpath)
1021322
def filepaths(self):
        
        if self.path is not None:
            yield from utils.filepaths(self.path, exclude=self.exclude,
                                       hidden=False, empty=False)
1106061
def walk(self, root):
        
        files = []
        folders = []
        
        for relpath in self.listdir(root):
            if self.isfile(root + '/' + relpath):
                files.append(relpath)
            else:
                folders.append(relpath)
        
        yield root, folders, files
        
        for folder in folders:
            folderpath = root + '/' + folder
            for sub_root, sub_folders, sub_files in self.walk(folderpath):
                yield sub_root, sub_folders, sub_files
74954
def files(self):
        
        info = self.metainfo['info']
        if 'length' in info:    # Singlefile
            yield info['name']
        elif 'files' in info:   # Multifile torrent
            rootdir = self.name
            for fileinfo in info['files']:
                yield os.path.join(rootdir, os.path.join(*fileinfo['path']))
305823
private static Set<File> findAllFiles(File dir) {
        Set<File> foundFiles = new HashSet<>();
        if (dir == null) {
            return foundFiles;
        }
        recurse(dir, foundFiles);
        return foundFiles;
    }
466694
def files(self, paths, access=None, extensions=None, minsize=None):
        """"""
        self.failures = [path for path in paths if not
                         isvalid(path, access, extensions, 'file', minsize)]

        return not self.failures
1313799
def listdirs(path='.'):
    """"""
    import os
    for f in os.listdir(path):
        if isdir(join(path, f)):
            yield join(path, f) if path != '.' else f
155878
def files(self):
        """"""
        contents = self.paths
        contents = (BinFile(path.path) for path in contents if path.is_file)
        return contents
816005
private Collection<File> doListAllFiles(File rootDir,
                                            boolean includeDirectories) {
        Collection<File> result = new Stack<File>();
        File[] files = rootDir.listFiles();
        for (File f : files) {
            if (f.isDirectory()) {
                if (includeDirectories) {
                    result.add(f);
                }
                result.addAll(doListAllFiles(f, includeDirectories));
            } else if (f.isFile()) {
                result.add(f);
            }
        }
        return result;
    }
133852
def find_data(folder):
    
    for (path, directories, filenames) in os.walk(folder):
        for filename in filenames:
            yield os.path.join('..', path, filename)