Skip to content

Commit

Permalink
Merge pull request #62 from sldouglas-nist/add_kwargs_to_NTFSFile
Browse files Browse the repository at this point in the history
  • Loading branch information
williballenthin authored Jul 28, 2023
2 parents 748c541 + e2f7e52 commit ad785cc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 35 deletions.
35 changes: 18 additions & 17 deletions indxparse/MFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,23 +1283,24 @@ def active_data(self) -> bytes:


class NTFSFile:
def __init__(self, options):
if type(options) == dict:
self.filename = options["filename"]
self.filetype = options["filetype"] or "mft"
self.offset = options["offset"] or 0
self.clustersize = options["clustersize"] or 4096
self.mftoffset = False
self.prefix = options["prefix"] or None
self.progress = options["progress"]
else:
self.filename = options.filename
self.filetype = options.filetype
self.offset = options.offset
self.clustersize = options.clustersize
self.mftoffset = False
self.prefix = options.prefix
self.progress = options.progress
def __init__(
self,
*args: typing.Any,
clustersize: int = 4096,
filename: str,
filetype: str,
offset: int = 0,
prefix: str,
progress: bool = False,
**kwargs: typing.Any
) -> None:
self.clustersize = clustersize
self.filename = filename
self.filetype = filetype
self.offset = offset
self.mftoffset = False
self.prefix = prefix or None
self.progress = progress

# TODO calculate cluster size

Expand Down
18 changes: 16 additions & 2 deletions indxparse/MFTINDX.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,14 @@ def print_nonresident_indx_bodyfile(options, buf, basepath=""):

def print_bodyfile(options):
if options.filetype == "mft" or options.filetype == "image":
f = NTFSFile(options)
f = NTFSFile(
clustersize=options.clustersize,
filename=options.filename,
filetype=options.filetype,
offset=options.offset,
prefix=options.prefix,
progress=options.progress,
)
if options.filter:
refilter = re.compile(options.filter)
for record in f.record_generator():
Expand Down Expand Up @@ -305,7 +312,14 @@ def print_bodyfile(options):


def print_indx_info(options):
f = NTFSFile(options)
f = NTFSFile(
clustersize=options.clustersize,
filename=options.filename,
filetype=options.filetype,
offset=options.offset,
prefix=options.prefix,
progress=options.progress,
)
try:
record_num = int(options.infomode)
record_buf = f.mft_get_record_buf(record_num)
Expand Down
28 changes: 12 additions & 16 deletions indxparse/MFTView.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,12 @@ def fetch(self, progress_fn=nop):
f.seek(0)

f = NTFSFile(
{
"filename": self._filename,
"filetype": "mft",
"offset": 0,
"clustersize": 4096,
"prefix": "C:",
"progress": False,
}
clustersize=4096,
filename=self._filename,
filetype="mft",
offset=0,
prefix="C:",
progress=False,
)

class RecordConflict(Exception):
Expand Down Expand Up @@ -1360,14 +1358,12 @@ def OnFileSelected(self, event):
rec_num = self._tree.GetPyData(item)["rec_num"]

f = NTFSFile(
{
"filename": self._filename,
"filetype": "mft",
"offset": 0,
"clustersize": 4096,
"prefix": "C:",
"progress": False,
}
clustersize=4096,
filename=self._filename,
filetype="mft",
offset=0,
prefix="C:",
progress=False,
)

try:
Expand Down

0 comments on commit ad785cc

Please sign in to comment.