Skip to content

Commit

Permalink
Changes to use st_birthtime for Windows Python 3.12 #764
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 7, 2024
1 parent bac40ae commit cb877ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dfvfs/vfs/os_file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import platform
import stat
import sys

import pysmdev

Expand All @@ -28,6 +29,7 @@ class OSFileEntry(file_entry.FileEntry):
TYPE_INDICATOR = definitions.TYPE_INDICATOR_OS

_OS_IS_WINDOWS = platform.system() == 'Windows'
_PY_3_11_AND_EARLIER = bool(tuple(sys.version_info[0:2]) <= (3, 11))

def __init__(self, resolver_context, file_system, path_spec, is_root=False):
"""Initializes a file entry.
Expand Down Expand Up @@ -226,7 +228,7 @@ def creation_time(self):

# Per Python os.stat() documentation the value of stat_results.st_ctime
# contains the creation time on Windows.
if self._OS_IS_WINDOWS:
if self._OS_IS_WINDOWS and self._PY_3_11_AND_EARLIER:
timestamp = getattr(self._stat_info, 'st_ctime_ns', None)
if timestamp is not None:
return dfdatetime_posix_time.PosixTimeInNanoseconds(timestamp=timestamp)
Expand Down

0 comments on commit cb877ee

Please sign in to comment.