Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit bc158c5

Browse files
authored
Merge pull request #161 from armtash/file_atime
add atime to returned file data
2 parents 08a0193 + 7279f02 commit bc158c5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Each line of the JSON file records 1 _piece of information_. There are some com
148148

149149
##### File Records
150150
For records representing files there are a bunch of useful keys:
151+
* `atime`: The file accessed time.
151152
* `ctime`: The file creation time.
152153
* `mtime`: The file modified time.
153154
* `file_path`: The absolute path to the file.

osxcollector/osxcollector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,14 @@ def _get_file_info(file_path, log_xattr=False):
289289
dict with key ['md5', 'sha1', 'sha2', file_path', 'mtime', 'ctime']
290290
"""
291291
md5_hash, sha1_hash, sha2_hash = '', '', ''
292+
atime = ''
292293
mtime = ''
293294
ctime = ''
294295
extra_data_check = ''
295296
extra_data_found = False
296297

297298
if os.path.isfile(file_path):
299+
atime = _datetime_to_string(datetime.fromtimestamp(os.path.getatime(file_path)))
298300
mtime = _datetime_to_string(datetime.fromtimestamp(os.path.getmtime(file_path)))
299301
ctime = _datetime_to_string(datetime.fromtimestamp(os.path.getctime(file_path)))
300302
md5_hash, sha1_hash, sha2_hash = _hash_file(file_path)
@@ -315,6 +317,7 @@ def _get_file_info(file_path, log_xattr=False):
315317
'sha1': sha1_hash,
316318
'sha2': sha2_hash,
317319
'file_path': file_path,
320+
'atime': atime,
318321
'mtime': mtime,
319322
'ctime': ctime,
320323
'extra_data_check': extra_data_check,

0 commit comments

Comments
 (0)