From 5e96a5c44c3c78a901d77297517fa4842a297eb9 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 8 Dec 2019 22:51:49 +0100 Subject: Windows: enhancements to the mechanism preserving file timestamps, especially for keyfiles. --- src/Common/Format.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/Common/Format.c') diff --git a/src/Common/Format.c b/src/Common/Format.c index bd33f754..82c4df55 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -350,6 +350,19 @@ begin_format: nStatus = ERR_OS_ERROR; goto error; } + else if (volParams->hiddenVol && bPreserveTimestamp) + { + // ensure that Last Access and Last Write timestamps are not modified + ftLastAccessTime.dwHighDateTime = 0xFFFFFFFF; + ftLastAccessTime.dwLowDateTime = 0xFFFFFFFF; + + SetFileTime (dev, NULL, &ftLastAccessTime, NULL); + + if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) + bTimeStampValid = FALSE; + else + bTimeStampValid = TRUE; + } DisableFileCompression (dev); @@ -380,14 +393,6 @@ begin_format: } } - if (volParams->hiddenVol && !volParams->bDevice && bPreserveTimestamp) - { - if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) - bTimeStampValid = FALSE; - else - bTimeStampValid = TRUE; - } - if (volParams->hwndDlg && volParams->bGuiMode) KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW); /* Volume header */ -- cgit v1.2.3