From 26776f991cdc96f1dcfb1895b9734dfd9f337e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Fri, 10 Jan 2025 11:26:34 +0100 Subject: [PATCH] Fix error in calculation of file timestamp on Windows (bug #31080). * liboctave/system/oct-time.h (file_time::file_time (OCTAVE_WIN_FILETIME&)), liboctave/system/oct-time.cc (file_time::file_time (), file_time::file_time (const std::string&)): Shift high order bits in the correct direction. (grafted from b11d73d38936c345fa188b0e9e863167f9c428b2) --- liboctave/system/oct-time.cc | 8 ++++---- liboctave/system/oct-time.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/liboctave/system/oct-time.cc b/liboctave/system/oct-time.cc index 94cb68a678..721b28b991 100644 --- a/liboctave/system/oct-time.cc +++ b/liboctave/system/oct-time.cc @@ -378,8 +378,8 @@ file_time::file_time () FILETIME curr_file_time; GetSystemTimeAsFileTime (&curr_file_time); m_time - = (static_cast (curr_file_time.dwHighDateTime)) >> 32 - | curr_file_time.dwLowDateTime; + = (static_cast (curr_file_time.dwHighDateTime)) << 32 + | (static_cast (curr_file_time.dwLowDateTime)); #else time_t ot_unix_time; long ot_usec; @@ -405,8 +405,8 @@ file_time::file_time (const std::string& filename) FILETIME last_write_time = file_attributes.ftLastWriteTime; m_time - = (static_cast (last_write_time.dwHighDateTime)) >> 32 - | last_write_time.dwLowDateTime; + = (static_cast (last_write_time.dwHighDateTime)) << 32 + | (static_cast (last_write_time.dwLowDateTime)); #else file_stat fs = file_stat (filename); m_time = fs.mtime ().unix_time (); diff --git a/liboctave/system/oct-time.h b/liboctave/system/oct-time.h index 2de88b1d0c..bd63346eea 100644 --- a/liboctave/system/oct-time.h +++ b/liboctave/system/oct-time.h @@ -492,8 +492,8 @@ class OCTAVE_API file_time #if defined (OCTAVE_USE_WINDOWS_API) file_time (OCTAVE_WIN_FILETIME& t) { - m_time = (static_cast (t.dwHighDateTime)) >> 32 - | t.dwLowDateTime; + m_time = (static_cast (t.dwHighDateTime)) << 32 + | (static_cast (t.dwLowDateTime)); } #endif