Skip to content

Commit

Permalink
Changes to replace stat with attributes log2timeline#52
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jul 4, 2017
1 parent 07549e7 commit 59b04ce
Showing 1 changed file with 61 additions and 34 deletions.
95 changes: 61 additions & 34 deletions dfvfs/vfs/ntfs_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,45 +358,12 @@ def _GetStat(self):
if not fsntfs_file_entry:
raise errors.BackEndError(u'Missing pyfsntfs file entry.')

stat_object = vfs_stat.VFSStat()
stat_object = super(ZipFileEntry, self)._GetStat()

# File data stat information.
if fsntfs_file_entry.has_default_data_stream():
stat_object.size = fsntfs_file_entry.get_size()

# Date and time stat information.
timestamp = fsntfs_file_entry.get_access_time_as_integer()
date_time_values = dfdatetime_filetime.Filetime(timestamp=timestamp)

stat_time, stat_time_nano = date_time_values.CopyToStatTimeTuple()
if stat_time is not None:
stat_object.atime = stat_time
stat_object.atime_nano = stat_time_nano

timestamp = fsntfs_file_entry.get_creation_time_as_integer()
date_time_values = dfdatetime_filetime.Filetime(timestamp=timestamp)

stat_time, stat_time_nano = date_time_values.CopyToStatTimeTuple()
if stat_time is not None:
stat_object.crtime = stat_time
stat_object.crtime_nano = stat_time_nano

timestamp = fsntfs_file_entry.get_modification_time_as_integer()
date_time_values = dfdatetime_filetime.Filetime(timestamp=timestamp)

stat_time, stat_time_nano = date_time_values.CopyToStatTimeTuple()
if stat_time is not None:
stat_object.mtime = stat_time
stat_object.mtime_nano = stat_time_nano

timestamp = fsntfs_file_entry.get_entry_modification_time_as_integer()
date_time_values = dfdatetime_filetime.Filetime(timestamp=timestamp)

stat_time, stat_time_nano = date_time_values.CopyToStatTimeTuple()
if stat_time is not None:
stat_object.ctime = stat_time
stat_object.ctime_nano = stat_time_nano

# Ownership and permissions stat information.
# TODO: stat_object.mode
# TODO: stat_object.uid
Expand Down Expand Up @@ -428,6 +395,51 @@ def _IsLink(self, file_attribute_flags):
return bool(
file_attribute_flags & pyfsntfs.file_attribute_flags.REPARSE_POINT)

@property
def access_time(self):
"""dfdatetime.DateTimeValues: access time or None if not available.
Raises:
BackEndError: if the pyfsntfs file entry is missing.
"""
fsntfs_file_entry = self.GetNTFSFileEntry()
if not fsntfs_file_entry:
raise errors.BackEndError(u'Missing pyfsntfs file entry.')

timestamp = fsntfs_file_entry.get_access_time_as_integer()
if timestamp:
return dfdatetime_filetime.Filetime(timestamp=timestamp)

@property
def change_time(self):
"""dfdatetime.DateTimeValues: change time or None if not available.
Raises:
BackEndError: if the pyfsntfs file entry is missing.
"""
fsntfs_file_entry = self.GetNTFSFileEntry()
if not fsntfs_file_entry:
raise errors.BackEndError(u'Missing pyfsntfs file entry.')

timestamp = fsntfs_file_entry.get_entry_modification_time_as_integer()
if timestamp:
return dfdatetime_filetime.Filetime(timestamp=timestamp)

@property
def creation_time(self):
"""dfdatetime.DateTimeValues: creation time or None if not available.
Raises:
BackEndError: if the pyfsntfs file entry is missing.
"""
fsntfs_file_entry = self.GetNTFSFileEntry()
if not fsntfs_file_entry:
raise errors.BackEndError(u'Missing pyfsntfs file entry.')

timestamp = fsntfs_file_entry.get_creation_time_as_integer()
if timestamp:
return dfdatetime_filetime.Filetime(timestamp=timestamp)

@property
def name(self):
"""str: name of the file entry, which does not include the full path.
Expand All @@ -448,6 +460,21 @@ def name(self):
return fsntfs_file_entry.get_name_by_attribute_index(mft_attribute)
return fsntfs_file_entry.get_name()

@property
def modification_time(self):
"""dfdatetime.DateTimeValues: modification time or None if not available.
Raises:
BackEndError: if the pyfsntfs file entry is missing.
"""
fsntfs_file_entry = self.GetNTFSFileEntry()
if not fsntfs_file_entry:
raise errors.BackEndError(u'Missing pyfsntfs file entry.')

timestamp = fsntfs_file_entry.get_modification_time_as_integer()
if timestamp:
return dfdatetime_filetime.Filetime(timestamp=timestamp)

@property
def sub_file_entries(self):
"""generator(NTFSFileEntry): sub file entries."""
Expand Down

0 comments on commit 59b04ce

Please sign in to comment.