Skip to content

Commit

Permalink
Added size property to ext, HFS and XFS file entry (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Oct 18, 2021
1 parent 068b162 commit d6adda4
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dfvfs (20210918-1) unstable; urgency=low
dfvfs (20211017-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline maintainers <[email protected]> Sat, 18 Sep 2021 10:24:40 +0200
-- Log2Timeline maintainers <[email protected]> Sun, 17 Oct 2021 18:27:40 +0200
2 changes: 2 additions & 0 deletions dependencies.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ rpm_name: python3-dtfabric
version_property: __version__

[idna]
skip_check: true
skip_requires: true
dpkg_name: python3-idna
minimum_version: 2.5
rpm_name: python3-idna
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
storage media types and file formats.
"""

__version__ = '20210918'
__version__ = '20211017'
4 changes: 2 additions & 2 deletions dfvfs/vfs/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class StatAttribute(object):
inode_number (int): number of the corresponding inode, equivalent to st_ino.
mode (int): access mode, equivalent to st_mode & 0x0fff.
number_of_links (int): number of hard links, equivalent to st_nlink.
owner_user_identifier (int): user identifier (UID) of the owner, equivalent
to st_uid.
owner_identifier (int): user identifier (UID) of the owner, equivalent to
st_uid.
size (int): size, in number of bytes, equivalent to st_size.
type (str): file type, value derived from st_mode >> 12.
"""
Expand Down
5 changes: 5 additions & 0 deletions dfvfs/vfs/ext_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ def modification_time(self):

return dfdatetime_posix_time.PosixTimeInNanoseconds(timestamp=timestamp)

@property
def size(self):
"""int: size of the file entry in bytes or None if not available."""
return self._fsext_file_entry.size

def GetEXTFileEntry(self):
"""Retrieves the EXT file entry.
Expand Down
5 changes: 5 additions & 0 deletions dfvfs/vfs/hfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def modification_time(self):
timestamp = self._fshfs_file_entry.get_modification_time_as_integer()
return dfdatetime_hfs_time.HFSTime(timestamp=timestamp)

@property
def size(self):
"""int: size of the file entry in bytes or None if not available."""
return self._fshfs_file_entry.size

def GetHFSFileEntry(self):
"""Retrieves the HFS file entry.
Expand Down
5 changes: 5 additions & 0 deletions dfvfs/vfs/xfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ def modification_time(self):
timestamp = self._fsxfs_file_entry.get_modification_time_as_integer()
return dfdatetime_posix_time.PosixTimeInNanoseconds(timestamp=timestamp)

@property
def size(self):
"""int: size of the file entry in bytes or None if not available."""
return self._fsxfs_file_entry.size

def GetXFSFileEntry(self):
"""Retrieves the XFS file entry.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cffi >= 1.9.1
cryptography >= 2.0.2
dfdatetime >= 20210509
dtfabric >= 20170524
idna >= 2.5
libbde-python >= 20140531
libewf-python >= 20131210
libfsapfs-python >= 20201107
Expand Down
11 changes: 11 additions & 0 deletions tests/vfs/ext_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ def testModificationTime(self):
self.assertIsNotNone(file_entry)
self.assertIsNotNone(file_entry.modification_time)

def testSize(self):
"""Test the size property."""
test_location = '/a_directory/another_file'
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.TYPE_INDICATOR_EXT, inode=self._INODE_ANOTHER_FILE,
location=test_location, parent=self._raw_path_spec)
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)

self.assertIsNotNone(file_entry)
self.assertEqual(file_entry.size, 22)

def testGetFileEntryByPathSpec(self):
"""Tests the GetFileEntryByPathSpec function."""
path_spec = path_spec_factory.Factory.NewPathSpec(
Expand Down
12 changes: 12 additions & 0 deletions tests/vfs/hfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ def testModificationTime(self):
self.assertIsNotNone(file_entry)
self.assertIsNotNone(file_entry.modification_time)

def testSize(self):
"""Test the size property."""
test_location = '/a_directory/another_file'
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.TYPE_INDICATOR_HFS,
identifier=self._IDENTIFIER_ANOTHER_FILE, location=test_location,
parent=self._raw_path_spec)
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)

self.assertIsNotNone(file_entry)
self.assertEqual(file_entry.size, 22)

def testGetAttributes(self):
"""Tests the _GetAttributes function."""
test_location = '/a_directory/a_file'
Expand Down
11 changes: 11 additions & 0 deletions tests/vfs/xfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ def testModificationTime(self):
self.assertIsNotNone(file_entry)
self.assertIsNotNone(file_entry.modification_time)

def testSize(self):
"""Test the size property."""
test_location = '/a_directory/another_file'
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.TYPE_INDICATOR_XFS, inode=self._INODE_ANOTHER_FILE,
location=test_location, parent=self._raw_path_spec)
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)

self.assertIsNotNone(file_entry)
self.assertEqual(file_entry.size, 22)

def testGetAttributes(self):
"""Tests the _GetAttributes function."""
test_location = '/a_directory/a_file'
Expand Down

0 comments on commit d6adda4

Please sign in to comment.