dissect.ntfs 3.10.dev2__tar.gz → 3.10.dev4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {dissect.ntfs-3.10.dev2/dissect.ntfs.egg-info → dissect.ntfs-3.10.dev4}/PKG-INFO +1 -1
  2. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/mft.py +12 -4
  3. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4/dissect.ntfs.egg-info}/PKG-INFO +1 -1
  4. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_mft.py +15 -0
  5. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/COPYRIGHT +0 -0
  6. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/LICENSE +0 -0
  7. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/MANIFEST.in +0 -0
  8. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/README.md +0 -0
  9. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/__init__.py +0 -0
  10. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/attr.py +0 -0
  11. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/c_ntfs.py +0 -0
  12. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/exceptions.py +0 -0
  13. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/index.py +0 -0
  14. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/ntfs.py +0 -0
  15. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/secure.py +0 -0
  16. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/stream.py +0 -0
  17. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/usnjrnl.py +0 -0
  18. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect/ntfs/util.py +0 -0
  19. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect.ntfs.egg-info/SOURCES.txt +0 -0
  20. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect.ntfs.egg-info/dependency_links.txt +0 -0
  21. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect.ntfs.egg-info/requires.txt +0 -0
  22. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/dissect.ntfs.egg-info/top_level.txt +0 -0
  23. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/pyproject.toml +0 -0
  24. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/setup.cfg +0 -0
  25. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/__init__.py +0 -0
  26. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/conftest.py +0 -0
  27. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/boot_2m.bin.gz +0 -0
  28. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/mft.bin.gz +0 -0
  29. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/ntfs.bin.gz +0 -0
  30. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/ntfs_fragmented_mft.csv.gz +0 -0
  31. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/sds.bin.gz +0 -0
  32. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/data/sds_complex.bin.gz +0 -0
  33. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/docs/Makefile +0 -0
  34. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/docs/conf.py +0 -0
  35. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/docs/index.rst +0 -0
  36. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_attr.py +0 -0
  37. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_index.py +0 -0
  38. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_ntfs.py +0 -0
  39. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_secure.py +0 -0
  40. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_usnjrnl.py +0 -0
  41. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tests/test_util.py +0 -0
  42. {dissect.ntfs-3.10.dev2 → dissect.ntfs-3.10.dev4}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.ntfs
3
- Version: 3.10.dev2
3
+ Version: 3.10.dev4
4
4
  Summary: A Dissect module implementing a parser for the NTFS file system, used by the Windows operating system
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -120,12 +120,20 @@ class Mft:
120
120
  else:
121
121
  raise TypeError(f"Invalid MFT reference: {ref!r}")
122
122
 
123
- def segments(self) -> Iterator[MftRecord]:
124
- """Yield all valid MFT records, regardless if they're allocated or not."""
123
+ def segments(self, start: int = 0, end: int = -1) -> Iterator[MftRecord]:
124
+ """Yield all valid MFT records, regardless if they're allocated or not.
125
+
126
+ Args:
127
+ start: The starting segment number. Use ``-1`` to start from the last segment.
128
+ end: The ending segment number. Use ``-1`` to end with the last segment.
129
+ """
125
130
  record_size = self.ntfs._record_size if self.ntfs else DEFAULT_RECORD_SIZE
126
- mft_size = self.get(FILE_NUMBER_MFT).size()
131
+ last_segment = self.get(FILE_NUMBER_MFT).size() // record_size
132
+ start = last_segment if start == -1 else start
133
+ end = last_segment if end == -1 else end
134
+ step = 1 if start <= end else -1
127
135
 
128
- for segment in range(mft_size // record_size):
136
+ for segment in range(start, end + step, step):
129
137
  try:
130
138
  yield self.get(segment)
131
139
  except Error:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.ntfs
3
- Version: 3.10.dev2
3
+ Version: 3.10.dev4
4
4
  Summary: A Dissect module implementing a parser for the NTFS file system, used by the Windows operating system
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -79,3 +79,18 @@ def test_mft_record() -> None:
79
79
  record = mft.get(0)
80
80
  assert record.filename == "$MFT"
81
81
  assert record.filenames() == ["$MFT"]
82
+
83
+
84
+ def test_mft_records_segment_number(mft_bin: BinaryIO) -> None:
85
+ fs = NTFS(mft=mft_bin)
86
+ assert fs.mft
87
+
88
+ records_forward = list(fs.mft.segments(0, 4))
89
+ assert len(records_forward) == 5
90
+ assert records_forward[0].filename == "$MFT"
91
+ assert records_forward[4].filename == "$AttrDef"
92
+
93
+ records_backwards = list(fs.mft.segments(4, 0))
94
+ assert len(records_backwards) == 5
95
+ assert records_backwards[0].filename == "$AttrDef"
96
+ assert records_backwards[4].filename == "$MFT"