-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
26aa235
commit 823e978
Showing
18 changed files
with
902 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The HFS data stream implementation.""" | ||
|
||
from dfvfs.lib import definitions | ||
from dfvfs.vfs import data_stream | ||
from dfvfs.vfs import extent | ||
|
||
|
||
class HFSDataStream(data_stream.DataStream): | ||
"""File system data stream that uses pyfshfs.""" | ||
|
||
def __init__(self, fshfs_data_stream): | ||
"""Initializes the data stream. | ||
def __init__(self, file_entry, fshfs_data_stream): | ||
"""Initializes a HFS data stream. | ||
Args: | ||
file_entry (FileEntry): file entry. | ||
fshfs_data_stream (pyfshfs.data_stream): HFS data stream. | ||
""" | ||
super(HFSDataStream, self).__init__() | ||
super(HFSDataStream, self).__init__(file_entry) | ||
self._fshfs_data_stream = fshfs_data_stream | ||
self._name = '' | ||
|
||
if fshfs_data_stream: | ||
self._name = 'rsrc' | ||
|
||
@property | ||
def name(self): | ||
"""str: name.""" | ||
return self._name | ||
|
||
def IsDefault(self): | ||
"""Determines if the data stream is the default (data fork) data stream. | ||
def GetExtents(self): | ||
"""Retrieves the extents. | ||
Returns: | ||
bool: True if the data stream is the default (data fork) data stream. | ||
list[Extent]: the extents of the data stream. | ||
""" | ||
return not self._fshfs_data_stream | ||
if not self._fshfs_data_stream: | ||
return super(HFSDataStream, self).GetExtents() | ||
|
||
extents = [] | ||
for extent_index in range(self._fshfs_data_stream.number_of_extents): | ||
extent_offset, extent_size, extent_flags = ( | ||
self._fshfs_data_stream.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The NTFS data stream implementation.""" | ||
|
||
from dfvfs.lib import definitions | ||
from dfvfs.vfs import data_stream | ||
from dfvfs.vfs import extent | ||
|
||
|
||
class NTFSDataStream(data_stream.DataStream): | ||
"""File system data stream that uses pyfsntfs.""" | ||
|
||
def __init__(self, fsntfs_data_stream): | ||
"""Initializes the data stream. | ||
def __init__(self, file_entry, fsntfs_data_stream): | ||
"""Initializes a NTFS data stream. | ||
Args: | ||
file_entry (FileEntry): file entry. | ||
fsntfs_data_stream (pyfsntfs.data_stream): NTFS data stream. | ||
""" | ||
super(NTFSDataStream, self).__init__() | ||
self._name = getattr(fsntfs_data_stream, 'name', None) or '' | ||
super(NTFSDataStream, self).__init__(file_entry) | ||
self._fsntfs_data_stream = fsntfs_data_stream | ||
|
||
@property | ||
def name(self): | ||
"""str: name.""" | ||
return self._name | ||
if fsntfs_data_stream: | ||
self._name = fsntfs_data_stream.name | ||
|
||
def IsDefault(self): | ||
"""Determines if the data stream is the default data stream. | ||
def GetExtents(self): | ||
"""Retrieves the extents. | ||
Returns: | ||
bool: True if the data stream is the default data stream. | ||
list[Extent]: the extents of the data stream. | ||
""" | ||
return not bool(self._name) | ||
if not self._fsntfs_data_stream: | ||
return super(NTFSDataStream, self).GetExtents() | ||
|
||
extents = [] | ||
for extent_index in range(self._fsntfs_data_stream.number_of_extents): | ||
extent_offset, extent_size, extent_flags = ( | ||
self._fsntfs_data_stream.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 |
Oops, something went wrong.