diff --git a/config/dpkg/changelog b/config/dpkg/changelog index 9d1ea557..95f7baf2 100644 --- a/config/dpkg/changelog +++ b/config/dpkg/changelog @@ -1,5 +1,5 @@ -dfvfs (20220418-1) unstable; urgency=low +dfvfs (20220419-1) unstable; urgency=low * Auto-generated - -- Log2Timeline maintainers Mon, 18 Apr 2022 16:15:40 +0200 + -- Log2Timeline maintainers Tue, 19 Apr 2022 11:17:49 +0200 diff --git a/dfvfs/__init__.py b/dfvfs/__init__.py index 4ade628e..14f1f743 100644 --- a/dfvfs/__init__.py +++ b/dfvfs/__init__.py @@ -6,4 +6,4 @@ storage media types and file formats. """ -__version__ = '20220418' +__version__ = '20220419' diff --git a/dfvfs/vfs/apfs_directory.py b/dfvfs/vfs/apfs_directory.py index 55fe461e..edcb4c51 100644 --- a/dfvfs/vfs/apfs_directory.py +++ b/dfvfs/vfs/apfs_directory.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """The APFS directory implementation.""" -from dfvfs.lib import errors from dfvfs.path import apfs_path_spec from dfvfs.vfs import directory @@ -9,6 +8,17 @@ class APFSDirectory(directory.Directory): """File system directory that uses pyfsapfs.""" + def __init__(self, file_system, path_spec, fsapfs_file_entry): + """Initializes a directory. + + Args: + file_system (FileSystem): file system. + path_spec (PathSpec): path specification. + fsapfs_file_entry (pyfsapfs.file_entry): APFS file entry. + """ + super(APFSDirectory, self).__init__(file_system, path_spec) + self._fsapfs_file_entry = fsapfs_file_entry + def _EntriesGenerator(self): """Retrieves directory entries. @@ -18,15 +28,9 @@ def _EntriesGenerator(self): Yields: APFSPathSpec: APFS path specification. """ - 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: + for fsapfs_sub_file_entry in self._fsapfs_file_entry.sub_file_entries: directory_entry = fsapfs_sub_file_entry.name if not location or location == self._file_system.PATH_SEPARATOR: diff --git a/dfvfs/vfs/apfs_file_entry.py b/dfvfs/vfs/apfs_file_entry.py index 09d5850f..5f16fe35 100644 --- a/dfvfs/vfs/apfs_file_entry.py +++ b/dfvfs/vfs/apfs_file_entry.py @@ -86,7 +86,8 @@ def _GetDirectory(self): if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY: return None - return apfs_directory.APFSDirectory(self._file_system, self.path_spec) + return apfs_directory.APFSDirectory( + self._file_system, self.path_spec, self._fsapfs_file_entry) def _GetLink(self): """Retrieves the link. diff --git a/dfvfs/vfs/ext_directory.py b/dfvfs/vfs/ext_directory.py index edf4abaf..7eb48218 100644 --- a/dfvfs/vfs/ext_directory.py +++ b/dfvfs/vfs/ext_directory.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """The EXT directory implementation.""" -from dfvfs.lib import errors from dfvfs.path import ext_path_spec from dfvfs.vfs import directory @@ -9,6 +8,17 @@ class EXTDirectory(directory.Directory): """File system directory that uses pyfsext.""" + def __init__(self, file_system, path_spec, fsext_file_entry): + """Initializes a directory. + + Args: + file_system (FileSystem): file system. + path_spec (PathSpec): path specification. + fsext_file_entry (pyfsext.file_entry): EXT file entry. + """ + super(EXTDirectory, self).__init__(file_system, path_spec) + self._fsext_file_entry = fsext_file_entry + def _EntriesGenerator(self): """Retrieves directory entries. @@ -18,15 +28,9 @@ def _EntriesGenerator(self): Yields: EXTPathSpec: EXT path specification. """ - try: - fsext_file_entry = self._file_system.GetEXTFileEntryByPathSpec( - self.path_spec) - except errors.PathSpecError: - return - location = getattr(self.path_spec, 'location', None) - for fsext_sub_file_entry in fsext_file_entry.sub_file_entries: + for fsext_sub_file_entry in self._fsext_file_entry.sub_file_entries: directory_entry = fsext_sub_file_entry.name if not location or location == self._file_system.PATH_SEPARATOR: diff --git a/dfvfs/vfs/ext_file_entry.py b/dfvfs/vfs/ext_file_entry.py index 2f1bf458..b7b05cbc 100644 --- a/dfvfs/vfs/ext_file_entry.py +++ b/dfvfs/vfs/ext_file_entry.py @@ -103,7 +103,8 @@ def _GetDirectory(self): if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY: return None - return ext_directory.EXTDirectory(self._file_system, self.path_spec) + return ext_directory.EXTDirectory( + self._file_system, self.path_spec, self._fsext_file_entry) def _GetLink(self): """Retrieves the link. diff --git a/dfvfs/vfs/hfs_directory.py b/dfvfs/vfs/hfs_directory.py index e6498b3b..2ae06c59 100644 --- a/dfvfs/vfs/hfs_directory.py +++ b/dfvfs/vfs/hfs_directory.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """The HFS directory implementation.""" -from dfvfs.lib import errors from dfvfs.path import hfs_path_spec from dfvfs.vfs import directory @@ -9,6 +8,17 @@ class HFSDirectory(directory.Directory): """File system directory that uses pyfshfs.""" + def __init__(self, file_system, path_spec, fshfs_file_entry): + """Initializes a directory. + + Args: + file_system (FileSystem): file system. + path_spec (PathSpec): path specification. + fshfs_file_entry (pyfshfs.file_entry): HFS file entry. + """ + super(HFSDirectory, self).__init__(file_system, path_spec) + self._fshfs_file_entry = fshfs_file_entry + def _EntriesGenerator(self): """Retrieves directory entries. @@ -18,15 +28,9 @@ def _EntriesGenerator(self): Yields: HFSPathSpec: HFS path specification. """ - try: - fshfs_file_entry = self._file_system.GetHFSFileEntryByPathSpec( - self.path_spec) - except errors.PathSpecError: - return - location = getattr(self.path_spec, 'location', None) - for fshfs_sub_file_entry in fshfs_file_entry.sub_file_entries: + for fshfs_sub_file_entry in self._fshfs_file_entry.sub_file_entries: directory_entry = fshfs_sub_file_entry.name if not location or location == self._file_system.PATH_SEPARATOR: diff --git a/dfvfs/vfs/hfs_file_entry.py b/dfvfs/vfs/hfs_file_entry.py index f081364a..7489df39 100644 --- a/dfvfs/vfs/hfs_file_entry.py +++ b/dfvfs/vfs/hfs_file_entry.py @@ -117,7 +117,8 @@ def _GetDirectory(self): if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY: return None - return hfs_directory.HFSDirectory(self._file_system, self.path_spec) + return hfs_directory.HFSDirectory( + self._file_system, self.path_spec, self._fshfs_file_entry) def _GetLink(self): """Retrieves the link. diff --git a/dfvfs/vfs/ntfs_directory.py b/dfvfs/vfs/ntfs_directory.py index 3bf7801a..75964165 100644 --- a/dfvfs/vfs/ntfs_directory.py +++ b/dfvfs/vfs/ntfs_directory.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """The NTFS directory implementation.""" -from dfvfs.lib import errors from dfvfs.path import ntfs_path_spec from dfvfs.vfs import directory @@ -11,6 +10,17 @@ class NTFSDirectory(directory.Directory): _FILE_REFERENCE_MFT_ENTRY_BITMASK = 0xffffffffffff + def __init__(self, file_system, path_spec, fsntfs_file_entry): + """Initializes a directory. + + Args: + file_system (FileSystem): file system. + path_spec (PathSpec): path specification. + fsntfs_file_entry (pyfsntfs.file_entry): NTFS file entry. + """ + super(NTFSDirectory, self).__init__(file_system, path_spec) + self._fsntfs_file_entry = fsntfs_file_entry + def _EntriesGenerator(self): """Retrieves directory entries. @@ -20,33 +30,26 @@ def _EntriesGenerator(self): Yields: NTFSPathSpec: NTFS path specification. """ - try: - fsntfs_file_entry = self._file_system.GetNTFSFileEntryByPathSpec( - self.path_spec) - except errors.PathSpecError: - fsntfs_file_entry = None - - if fsntfs_file_entry: - location = getattr(self.path_spec, 'location', None) - - for fsntfs_sub_file_entry in fsntfs_file_entry.sub_file_entries: - directory_entry = fsntfs_sub_file_entry.name - - # Ignore references to self or parent. - if directory_entry in ('.', '..'): - continue - - file_reference = fsntfs_sub_file_entry.file_reference - directory_entry_mft_entry = ( - file_reference & self._FILE_REFERENCE_MFT_ENTRY_BITMASK) - - if not location or 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 ntfs_path_spec.NTFSPathSpec( - location=directory_entry, - mft_attribute=fsntfs_sub_file_entry.name_attribute_index, - mft_entry=directory_entry_mft_entry, parent=self.path_spec.parent) + location = getattr(self.path_spec, 'location', None) + + for fsntfs_sub_file_entry in self._fsntfs_file_entry.sub_file_entries: + directory_entry = fsntfs_sub_file_entry.name + + # Ignore references to self or parent. + if directory_entry in ('.', '..'): + continue + + file_reference = fsntfs_sub_file_entry.file_reference + directory_entry_mft_entry = ( + file_reference & self._FILE_REFERENCE_MFT_ENTRY_BITMASK) + + if not location or 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 ntfs_path_spec.NTFSPathSpec( + location=directory_entry, + mft_attribute=fsntfs_sub_file_entry.name_attribute_index, + mft_entry=directory_entry_mft_entry, parent=self.path_spec.parent) diff --git a/dfvfs/vfs/ntfs_file_entry.py b/dfvfs/vfs/ntfs_file_entry.py index 1ddeb1e5..d5970815 100644 --- a/dfvfs/vfs/ntfs_file_entry.py +++ b/dfvfs/vfs/ntfs_file_entry.py @@ -114,7 +114,8 @@ def _GetDirectory(self): if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY: return None - return ntfs_directory.NTFSDirectory(self._file_system, self.path_spec) + return ntfs_directory.NTFSDirectory( + self._file_system, self.path_spec, self._fsntfs_file_entry) def _GetLink(self): """Retrieves the link. diff --git a/dfvfs/vfs/sqlite_blob_directory.py b/dfvfs/vfs/sqlite_blob_directory.py index 1de74613..ebf44d85 100644 --- a/dfvfs/vfs/sqlite_blob_directory.py +++ b/dfvfs/vfs/sqlite_blob_directory.py @@ -26,10 +26,6 @@ def _EntriesGenerator(self): Yields: SQLiteBlobPathSpec: a path specification. - - Raises: - AccessError: if the access to list the directory was denied. - BackEndError: if the directory could not be listed. """ table_name = getattr(self.path_spec, 'table_name', None) column_name = getattr(self.path_spec, 'column_name', None) diff --git a/dfvfs/vfs/xfs_directory.py b/dfvfs/vfs/xfs_directory.py index c3da5ac1..ebe51f96 100644 --- a/dfvfs/vfs/xfs_directory.py +++ b/dfvfs/vfs/xfs_directory.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """The XFS directory implementation.""" -from dfvfs.lib import errors from dfvfs.path import xfs_path_spec from dfvfs.vfs import directory @@ -9,6 +8,17 @@ class XFSDirectory(directory.Directory): """File system directory that uses pyfsxfs.""" + def __init__(self, file_system, path_spec, fsxfs_file_entry): + """Initializes a directory. + + Args: + file_system (FileSystem): file system. + path_spec (PathSpec): path specification. + fsxfs_file_entry (pyfsxfs.file_entry): XFS file entry. + """ + super(XFSDirectory, self).__init__(file_system, path_spec) + self._fsxfs_file_entry = fsxfs_file_entry + def _EntriesGenerator(self): """Retrieves directory entries. @@ -18,15 +28,9 @@ def _EntriesGenerator(self): Yields: XFSPathSpec: XFS path specification. """ - try: - fsxfs_file_entry = self._file_system.GetXFSFileEntryByPathSpec( - self.path_spec) - except errors.PathSpecError: - return - location = getattr(self.path_spec, 'location', None) - for fsxfs_sub_file_entry in fsxfs_file_entry.sub_file_entries: + for fsxfs_sub_file_entry in self._fsxfs_file_entry.sub_file_entries: directory_entry = fsxfs_sub_file_entry.name if not location or location == self._file_system.PATH_SEPARATOR: diff --git a/dfvfs/vfs/xfs_file_entry.py b/dfvfs/vfs/xfs_file_entry.py index 0f191b93..9574dc7d 100644 --- a/dfvfs/vfs/xfs_file_entry.py +++ b/dfvfs/vfs/xfs_file_entry.py @@ -100,7 +100,8 @@ def _GetDirectory(self): if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY: return None - return xfs_directory.XFSDirectory(self._file_system, self.path_spec) + return xfs_directory.XFSDirectory( + self._file_system, self.path_spec, self._fsxfs_file_entry) def _GetLink(self): """Retrieves the link. diff --git a/tests/vfs/apfs_directory.py b/tests/vfs/apfs_directory.py index 7f10a31c..c85e031a 100644 --- a/tests/vfs/apfs_directory.py +++ b/tests/vfs/apfs_directory.py @@ -43,15 +43,21 @@ def tearDown(self): def testInitialize(self): """Tests the __init__ function.""" + fsapfs_file_entry = self._file_system.GetAPFSFileEntryByPathSpec( + self._apfs_path_spec) + directory = apfs_directory.APFSDirectory( - self._file_system, self._apfs_path_spec) + self._file_system, self._apfs_path_spec, fsapfs_file_entry) self.assertIsNotNone(directory) def testEntriesGenerator(self): """Tests the _EntriesGenerator function.""" + fsapfs_file_entry = self._file_system.GetAPFSFileEntryByPathSpec( + self._apfs_path_spec) + directory = apfs_directory.APFSDirectory( - self._file_system, self._apfs_path_spec) + self._file_system, self._apfs_path_spec, fsapfs_file_entry) self.assertIsNotNone(directory) diff --git a/tests/vfs/ext_directory.py b/tests/vfs/ext_directory.py index b55b15ba..e8fdf2cc 100644 --- a/tests/vfs/ext_directory.py +++ b/tests/vfs/ext_directory.py @@ -40,15 +40,21 @@ def tearDown(self): def testInitialize(self): """Tests the __init__ function.""" + fsext_file_entry = self._file_system.GetEXTFileEntryByPathSpec( + self._ext_path_spec) + directory = ext_directory.EXTDirectory( - self._file_system, self._ext_path_spec) + self._file_system, self._ext_path_spec, fsext_file_entry) self.assertIsNotNone(directory) def testEntriesGenerator(self): """Tests the _EntriesGenerator function.""" + fsext_file_entry = self._file_system.GetEXTFileEntryByPathSpec( + self._ext_path_spec) + directory = ext_directory.EXTDirectory( - self._file_system, self._ext_path_spec) + self._file_system, self._ext_path_spec, fsext_file_entry) self.assertIsNotNone(directory) diff --git a/tests/vfs/hfs_directory.py b/tests/vfs/hfs_directory.py index 9e6619b1..5db9b09f 100644 --- a/tests/vfs/hfs_directory.py +++ b/tests/vfs/hfs_directory.py @@ -40,15 +40,21 @@ def tearDown(self): def testInitialize(self): """Tests the __init__ function.""" + fshfs_file_entry = self._file_system.GetHFSFileEntryByPathSpec( + self._hfs_path_spec) + directory = hfs_directory.HFSDirectory( - self._file_system, self._hfs_path_spec) + self._file_system, self._hfs_path_spec, fshfs_file_entry) self.assertIsNotNone(directory) def testEntriesGenerator(self): """Tests the _EntriesGenerator function.""" + fshfs_file_entry = self._file_system.GetHFSFileEntryByPathSpec( + self._hfs_path_spec) + directory = hfs_directory.HFSDirectory( - self._file_system, self._hfs_path_spec) + self._file_system, self._hfs_path_spec, fshfs_file_entry) self.assertIsNotNone(directory) diff --git a/tests/vfs/ntfs_directory.py b/tests/vfs/ntfs_directory.py index 0401d2fd..08b00222 100644 --- a/tests/vfs/ntfs_directory.py +++ b/tests/vfs/ntfs_directory.py @@ -40,15 +40,21 @@ def tearDown(self): def testInitialize(self): """Tests the __init__ function.""" + fsntfs_file_entry = self._file_system.GetNTFSFileEntryByPathSpec( + self._ntfs_path_spec) + directory = ntfs_directory.NTFSDirectory( - self._file_system, self._ntfs_path_spec) + self._file_system, self._ntfs_path_spec, fsntfs_file_entry) self.assertIsNotNone(directory) def testEntriesGenerator(self): """Tests the _EntriesGenerator function.""" + fsntfs_file_entry = self._file_system.GetNTFSFileEntryByPathSpec( + self._ntfs_path_spec) + directory = ntfs_directory.NTFSDirectory( - self._file_system, self._ntfs_path_spec) + self._file_system, self._ntfs_path_spec, fsntfs_file_entry) self.assertIsNotNone(directory) diff --git a/tests/vfs/xfs_directory.py b/tests/vfs/xfs_directory.py index aedde92e..205e9898 100644 --- a/tests/vfs/xfs_directory.py +++ b/tests/vfs/xfs_directory.py @@ -40,15 +40,21 @@ def tearDown(self): def testInitialize(self): """Tests the __init__ function.""" + fsxfs_file_entry = self._file_system.GetXFSFileEntryByPathSpec( + self._xfs_path_spec) + directory = xfs_directory.XFSDirectory( - self._file_system, self._xfs_path_spec) + self._file_system, self._xfs_path_spec, fsxfs_file_entry) self.assertIsNotNone(directory) def testEntriesGenerator(self): """Tests the _EntriesGenerator function.""" + fsxfs_file_entry = self._file_system.GetXFSFileEntryByPathSpec( + self._xfs_path_spec) + directory = xfs_directory.XFSDirectory( - self._file_system, self._xfs_path_spec) + self._file_system, self._xfs_path_spec, fsxfs_file_entry) self.assertIsNotNone(directory)