Skip to content

Commit d6adda4

Browse files
authored
Added size property to ext, HFS and XFS file entry (#604)
1 parent 068b162 commit d6adda4

11 files changed

+56
-6
lines changed

config/dpkg/changelog

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
dfvfs (20210918-1) unstable; urgency=low
1+
dfvfs (20211017-1) unstable; urgency=low
22

33
* Auto-generated
44

5-
-- Log2Timeline maintainers <[email protected]> Sat, 18 Sep 2021 10:24:40 +0200
5+
-- Log2Timeline maintainers <[email protected]> Sun, 17 Oct 2021 18:27:40 +0200

dependencies.ini

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ rpm_name: python3-dtfabric
2424
version_property: __version__
2525

2626
[idna]
27+
skip_check: true
28+
skip_requires: true
2729
dpkg_name: python3-idna
2830
minimum_version: 2.5
2931
rpm_name: python3-idna

dfvfs/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
storage media types and file formats.
77
"""
88

9-
__version__ = '20210918'
9+
__version__ = '20211017'

dfvfs/vfs/attribute.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class StatAttribute(object):
2121
inode_number (int): number of the corresponding inode, equivalent to st_ino.
2222
mode (int): access mode, equivalent to st_mode & 0x0fff.
2323
number_of_links (int): number of hard links, equivalent to st_nlink.
24-
owner_user_identifier (int): user identifier (UID) of the owner, equivalent
25-
to st_uid.
24+
owner_identifier (int): user identifier (UID) of the owner, equivalent to
25+
st_uid.
2626
size (int): size, in number of bytes, equivalent to st_size.
2727
type (str): file type, value derived from st_mode >> 12.
2828
"""

dfvfs/vfs/ext_file_entry.py

+5
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ def modification_time(self):
274274

275275
return dfdatetime_posix_time.PosixTimeInNanoseconds(timestamp=timestamp)
276276

277+
@property
278+
def size(self):
279+
"""int: size of the file entry in bytes or None if not available."""
280+
return self._fsext_file_entry.size
281+
277282
def GetEXTFileEntry(self):
278283
"""Retrieves the EXT file entry.
279284

dfvfs/vfs/hfs_file_entry.py

+5
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ def modification_time(self):
251251
timestamp = self._fshfs_file_entry.get_modification_time_as_integer()
252252
return dfdatetime_hfs_time.HFSTime(timestamp=timestamp)
253253

254+
@property
255+
def size(self):
256+
"""int: size of the file entry in bytes or None if not available."""
257+
return self._fshfs_file_entry.size
258+
254259
def GetHFSFileEntry(self):
255260
"""Retrieves the HFS file entry.
256261

dfvfs/vfs/xfs_file_entry.py

+5
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ def modification_time(self):
239239
timestamp = self._fsxfs_file_entry.get_modification_time_as_integer()
240240
return dfdatetime_posix_time.PosixTimeInNanoseconds(timestamp=timestamp)
241241

242+
@property
243+
def size(self):
244+
"""int: size of the file entry in bytes or None if not available."""
245+
return self._fsxfs_file_entry.size
246+
242247
def GetXFSFileEntry(self):
243248
"""Retrieves the XFS file entry.
244249

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ cffi >= 1.9.1
44
cryptography >= 2.0.2
55
dfdatetime >= 20210509
66
dtfabric >= 20170524
7-
idna >= 2.5
87
libbde-python >= 20140531
98
libewf-python >= 20131210
109
libfsapfs-python >= 20201107

tests/vfs/ext_file_entry.py

+11
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@ def testModificationTime(self):
431431
self.assertIsNotNone(file_entry)
432432
self.assertIsNotNone(file_entry.modification_time)
433433

434+
def testSize(self):
435+
"""Test the size property."""
436+
test_location = '/a_directory/another_file'
437+
path_spec = path_spec_factory.Factory.NewPathSpec(
438+
definitions.TYPE_INDICATOR_EXT, inode=self._INODE_ANOTHER_FILE,
439+
location=test_location, parent=self._raw_path_spec)
440+
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)
441+
442+
self.assertIsNotNone(file_entry)
443+
self.assertEqual(file_entry.size, 22)
444+
434445
def testGetFileEntryByPathSpec(self):
435446
"""Tests the GetFileEntryByPathSpec function."""
436447
path_spec = path_spec_factory.Factory.NewPathSpec(

tests/vfs/hfs_file_entry.py

+12
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ def testModificationTime(self):
117117
self.assertIsNotNone(file_entry)
118118
self.assertIsNotNone(file_entry.modification_time)
119119

120+
def testSize(self):
121+
"""Test the size property."""
122+
test_location = '/a_directory/another_file'
123+
path_spec = path_spec_factory.Factory.NewPathSpec(
124+
definitions.TYPE_INDICATOR_HFS,
125+
identifier=self._IDENTIFIER_ANOTHER_FILE, location=test_location,
126+
parent=self._raw_path_spec)
127+
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)
128+
129+
self.assertIsNotNone(file_entry)
130+
self.assertEqual(file_entry.size, 22)
131+
120132
def testGetAttributes(self):
121133
"""Tests the _GetAttributes function."""
122134
test_location = '/a_directory/a_file'

tests/vfs/xfs_file_entry.py

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ def testModificationTime(self):
101101
self.assertIsNotNone(file_entry)
102102
self.assertIsNotNone(file_entry.modification_time)
103103

104+
def testSize(self):
105+
"""Test the size property."""
106+
test_location = '/a_directory/another_file'
107+
path_spec = path_spec_factory.Factory.NewPathSpec(
108+
definitions.TYPE_INDICATOR_XFS, inode=self._INODE_ANOTHER_FILE,
109+
location=test_location, parent=self._raw_path_spec)
110+
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)
111+
112+
self.assertIsNotNone(file_entry)
113+
self.assertEqual(file_entry.size, 22)
114+
104115
def testGetAttributes(self):
105116
"""Tests the _GetAttributes function."""
106117
test_location = '/a_directory/a_file'

0 commit comments

Comments
 (0)