Skip to content

Commit

Permalink
Changes to expose data stream extents #597 (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Jan 13, 2022
1 parent 7b70305 commit 7abaa8c
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 66 deletions.
25 changes: 25 additions & 0 deletions dfvfs/vfs/apfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dfvfs.vfs import attribute
from dfvfs.vfs import apfs_attribute
from dfvfs.vfs import apfs_directory
from dfvfs.vfs import extent
from dfvfs.vfs import file_entry


Expand Down Expand Up @@ -207,6 +208,30 @@ def GetAPFSFileEntry(self):
"""
return self._fsapfs_file_entry

def GetExtents(self, data_stream_name=''):
"""Retrieves extents of a specific data stream.
Returns:
list[Extent]: extents of the data stream.
"""
extents = []
if (self.entry_type == definitions.FILE_ENTRY_TYPE_FILE and
not data_stream_name):
for extent_index in range(self._fsapfs_file_entry.number_of_extents):
extent_offset, extent_size, extent_flags = (
self._fsapfs_file_entry.get_extent(extent_index))

if extent_flags & 0x1:
extent_type = definitions.EXTENT_TYPE_SPARSE
else:
extent_type = definitions.EXTENT_TYPE_DATA

data_stream_extent = extent.Extent(
extent_type=extent_type, offset=extent_offset, size=extent_size)
extents.append(data_stream_extent)

return extents

def GetLinkedFileEntry(self):
"""Retrieves the linked file entry, e.g. for a symbolic link.
Expand Down
Loading

0 comments on commit 7abaa8c

Please sign in to comment.