dissect.target 3.8.dev34__py3-none-any.whl → 3.8.dev35__py3-none-any.whl
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.
- dissect/target/helpers/fsutil.py +18 -10
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/METADATA +1 -1
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/RECORD +8 -8
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/COPYRIGHT +0 -0
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/LICENSE +0 -0
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/WHEEL +0 -0
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/entry_points.txt +0 -0
- {dissect.target-3.8.dev34.dist-info → dissect.target-3.8.dev35.dist-info}/top_level.txt +0 -0
dissect/target/helpers/fsutil.py
CHANGED
@@ -5,8 +5,10 @@ Also contains some other filesystem related utilities.
|
|
5
5
|
|
6
6
|
from __future__ import annotations
|
7
7
|
|
8
|
+
import bz2
|
8
9
|
import errno
|
9
10
|
import fnmatch
|
11
|
+
import gzip
|
10
12
|
import hashlib
|
11
13
|
import io
|
12
14
|
import logging
|
@@ -973,7 +975,12 @@ def resolve_link(
|
|
973
975
|
def open_decompress(path: TargetPath, mode: str = "rb") -> Union[BinaryIO, TextIO]:
|
974
976
|
"""Open and decompress a file. Handles gz and bz2 files. Uncompressed files are opened as-is.
|
975
977
|
|
976
|
-
|
978
|
+
Args:
|
979
|
+
path: The path to the file to open and decompress. It is assumed this path exists.
|
980
|
+
mode: The mode in which to open the file.
|
981
|
+
|
982
|
+
Returns:
|
983
|
+
An binary or text IO stream, depending on the mode with which the file was opened.
|
977
984
|
|
978
985
|
Example:
|
979
986
|
bytes_buf = open_decompress(Path("/dir/file.gz")).read()
|
@@ -981,16 +988,17 @@ def open_decompress(path: TargetPath, mode: str = "rb") -> Union[BinaryIO, TextI
|
|
981
988
|
for line in open_decompress(Path("/dir/file.gz"), "rt"):
|
982
989
|
print(line)
|
983
990
|
"""
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
return bz2.open(
|
991
|
+
file = path.open()
|
992
|
+
magic = file.read(4)
|
993
|
+
file.seek(0)
|
994
|
+
|
995
|
+
if magic[:2] == b"\x1f\x8b":
|
996
|
+
return gzip.open(file, mode)
|
997
|
+
# In a valid bz2 header the 4th byte is in the range b'1' ... b'9'.
|
998
|
+
elif magic[:3] == b"BZh" and 0x31 <= magic[3] <= 0x39:
|
999
|
+
return bz2.open(file, mode)
|
993
1000
|
else:
|
1001
|
+
file.close()
|
994
1002
|
return path.open(mode)
|
995
1003
|
|
996
1004
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dissect.target
|
3
|
-
Version: 3.8.
|
3
|
+
Version: 3.8.dev35
|
4
4
|
Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
6
6
|
License: Affero General Public License v3
|
@@ -37,7 +37,7 @@ dissect/target/helpers/cache.py,sha256=3_akK2L4-aWhRJh_TxP8Eks3jY-PwpWBi-0R6MjAZ
|
|
37
37
|
dissect/target/helpers/config.py,sha256=7YCHHQfwlWuIAQHTqLVjdFSVYAB_xABiZYRPxXU6_Qw,1188
|
38
38
|
dissect/target/helpers/descriptor_extensions.py,sha256=uT8GwznfDAiIgMM7JKKOY0PXKMv2c0GCqJTCkWFgops,2605
|
39
39
|
dissect/target/helpers/docs.py,sha256=wxrhQKaV6F--Q4L69QwaXl-2EOZMp6POVnZ3_-9GeQE,4834
|
40
|
-
dissect/target/helpers/fsutil.py,sha256=
|
40
|
+
dissect/target/helpers/fsutil.py,sha256=LFSUF6X1JGw7LFT0h7lTEbEny6cjmiI8zE509Z_Dd-w,31695
|
41
41
|
dissect/target/helpers/hashutil.py,sha256=SSLl5BCAxiyanjEfDex0wSVu7D3uEbRKK3sRzRPePYY,2059
|
42
42
|
dissect/target/helpers/keychain.py,sha256=O4zYovoBhCZzaHxJy31Qf4qaosM82khdtHm0khybNfs,3099
|
43
43
|
dissect/target/helpers/lazy.py,sha256=4VnF-fUKor1K77Z09F4YnLpxM9PMHULzS9SJwVOnUS0,1799
|
@@ -251,10 +251,10 @@ dissect/target/volumes/bde.py,sha256=gYGg5yF9MNARwNzEkrEfZmKkxyZW4rhLkpdnPJCbhGk
|
|
251
251
|
dissect/target/volumes/disk.py,sha256=95grSsPt1BLVpKwTclwQYzPFGKTkFFqapIk0RoGWf38,968
|
252
252
|
dissect/target/volumes/lvm.py,sha256=zXAfszxNR6tOGrKAtAa_E-JhjI-sXQyR4VYLXD-kqCw,1616
|
253
253
|
dissect/target/volumes/vmfs.py,sha256=mlAJ8278tYaoRjk1u6tFFlCaDQUrVu5ZZE4ikiFvxi8,1707
|
254
|
-
dissect.target-3.8.
|
255
|
-
dissect.target-3.8.
|
256
|
-
dissect.target-3.8.
|
257
|
-
dissect.target-3.8.
|
258
|
-
dissect.target-3.8.
|
259
|
-
dissect.target-3.8.
|
260
|
-
dissect.target-3.8.
|
254
|
+
dissect.target-3.8.dev35.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
|
255
|
+
dissect.target-3.8.dev35.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
256
|
+
dissect.target-3.8.dev35.dist-info/METADATA,sha256=S4ko-GsgaonoytojPJM2DGAbtTSRxXCzZMxGVkxDk1Y,9752
|
257
|
+
dissect.target-3.8.dev35.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
258
|
+
dissect.target-3.8.dev35.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
|
259
|
+
dissect.target-3.8.dev35.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
|
260
|
+
dissect.target-3.8.dev35.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|