Retrieves directory entries.

    Since a directory can contain a vast number of entries using
    a generator is more memory efficient.

    Yields:
      APFSPathSpec: APFS path specification.
486406
def _EntriesGenerator(self):
    
    try:
      fsapfs_file_entry = self._file_system.GetAPFSFileEntryByPathSpec(
          self.path_spec)
    except errors.PathSpecError:
      return

    location = getattr(self.path_spec, 'location', None)

    for fsapfs_sub_file_entry in fsapfs_file_entry.sub_file_entries:
      directory_entry = fsapfs_sub_file_entry.name

      if location == self._file_system.PATH_SEPARATOR:
        directory_entry = self._file_system.JoinPath([directory_entry])
      else:
        directory_entry = self._file_system.JoinPath([
            location, directory_entry])

      yield apfs_path_spec.APFSPathSpec(
          identifier=fsapfs_sub_file_entry.identifier, location=directory_entry,
          parent=self.path_spec.parent)
946394
def get_folders(path):
        
        folder_paths = []

        for item in os.listdir(path):
            folder_path = os.path.join(path, item)

            if os.path.isdir(folder_path):
                folder_paths.append(folder_path)

        return folder_paths
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)
638941
def iter(self, dir_entries):
        
        filter = self.filter
        for entry in dir_entries:
            path = filter(Path2(entry.path))
            if path != False:
                yield path
51039
def _collect_infos(dirname):

    

    for r, _ds, fs in walk(dirname):
        if not islink(r) and r != dirname:
            i = ZipInfo()
            i.filename = join(relpath(r, dirname), "")
            i.file_size = 0
            i.compress_size = 0
            i.CRC = 0
            yield i.filename, i

        for f in fs:
            df = join(r, f)
            relfn = relpath(join(r, f), dirname)

            if islink(df):
                pass

            elif isfile(df):
                i = ZipInfo()
                i.filename = relfn
                i.file_size = getsize(df)
                i.compress_size = i.file_size
                i.CRC = file_crc32(df)
                yield i.filename, i

            else:
                # TODO: is there any more special treatment?
                pass
44244
def _GetDirectory(self):
    
    if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY:
      return None
    return TSKDirectory(self._file_system, self.path_spec)
838139
def _EntriesGenerator(self):
    
    volume_index = getattr(self.path_spec, 'volume_index', None)
    location = getattr(self.path_spec, 'location', None)

    # Only the virtual root file has directory entries.
    if (volume_index is None and location is not None and
        location == self._file_system.LOCATION_ROOT):
      vslvm_volume_group = self._file_system.GetLVMVolumeGroup()

      for volume_index in range(
          0, vslvm_volume_group.number_of_logical_volumes):
        location = '/lvm{0:d}'.format(volume_index + 1)
        yield lvm_path_spec.LVMPathSpec(
            location=location, parent=self.path_spec.parent,
            volume_index=volume_index)
1300615
def get_directories_with_extensions(self, start, extensions=None):
        
        return set([p.parent for ext in extensions for p in start.rglob(ext)])
176252
def _GetDirectory(self):
    
    if self._fsapfs_file_entry.number_of_sub_file_entries <= 0:
      return None

    return APFSDirectory(self._file_system, self.path_spec)
503914
def GetFileEntryByPathSpec(self, path_spec):
    
    return gzip_file_entry.GzipFileEntry(
        self._resolver_context, self, path_spec, is_root=True, is_virtual=True)
1133798
def dirs(self):
        """"""
        contents = self.paths
        contents = (VenvDir(path.path) for path in contents if path.is_dir)
        return contents
1128566
def _ExtractPathSpecsFromFile(self, file_entry):
    
    produced_main_path_spec = False
    for data_stream in file_entry.data_streams:
      # Make a copy so we don't make the changes on a path specification
      # directly. Otherwise already produced path specifications can be
      # altered in the process.
      path_spec = copy.deepcopy(file_entry.path_spec)
      if data_stream.name:
        setattr(path_spec, 'data_stream', data_stream.name)
      yield path_spec

      if not data_stream.name:
        produced_main_path_spec = True

    if not produced_main_path_spec:
      yield file_entry.path_spec
559009
@Override
    public Enumeration<String> getEntryPaths(String path, boolean recurse) {
        path = preSlashify(path);
        Iterator<Entry> entries;
        if (path.equals("/")) {
            // asking for entries of the root container
            entries = container.iterator();
        } else {
            Entry entry = container.getEntry(path);
            Container entryContainer = entry == null ? null : getContainer(entry);
            // Check if the entry is a container; 
            // if so only iterate over its entries if the container is not a root
            entries = entryContainer == null || entryContainer.isRoot() ? null : entryContainer.iterator();
            path = postSlashify(path, null);
        }
        return entries == null ? null : new ContainerEnumeration(path, entries, recurse);
    }
281529
def GetFileEntryByPathSpec(self, path_spec):
    
    row_index = getattr(path_spec, 'row_index', None)
    row_condition = getattr(path_spec, 'row_condition', None)

    # If no row_index or row_condition is provided, return a directory.
    if row_index is None and row_condition is None:
      return sqlite_blob_file_entry.SQLiteBlobFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    return sqlite_blob_file_entry.SQLiteBlobFileEntry(
        self._resolver_context, self, path_spec)
66225
def GetFileEntryByPathSpec(self, path_spec):
    
    return data_range_file_entry.DataRangeFileEntry(
        self._resolver_context, self, path_spec, is_root=True, is_virtual=True)
12479
def getdirs(self, section, option, raw=False, vars=None, fallback=[]):
        
        globs = self.getlist(section, option, fallback=[])
        return [f for g in globs for f in glob.glob(g) if os.path.isdir(f)]
980436
def GetFileEntries(self, path_prefix=''):
    
    if self._file_entries:
      for path, file_entry in iter(self._file_entries.items()):
        if path.startswith(path_prefix):
          yield file_entry