Skip to content

Commit

Permalink
Fix error in calculation of file timestamp on Windows (bug #31080).
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
mmuetzel committed Jan 10, 2025
1 parent 8c46a73 commit 26776f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions liboctave/system/oct-time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ file_time::file_time ()
FILETIME curr_file_time;
GetSystemTimeAsFileTime (&curr_file_time);
m_time
= (static_cast<OCTAVE_TIME_T> (curr_file_time.dwHighDateTime)) >> 32
| curr_file_time.dwLowDateTime;
= (static_cast<OCTAVE_TIME_T> (curr_file_time.dwHighDateTime)) << 32
| (static_cast<OCTAVE_TIME_T> (curr_file_time.dwLowDateTime));
#else
time_t ot_unix_time;
long ot_usec;
Expand All @@ -405,8 +405,8 @@ file_time::file_time (const std::string& filename)
FILETIME last_write_time = file_attributes.ftLastWriteTime;

m_time
= (static_cast<OCTAVE_TIME_T> (last_write_time.dwHighDateTime)) >> 32
| last_write_time.dwLowDateTime;
= (static_cast<OCTAVE_TIME_T> (last_write_time.dwHighDateTime)) << 32
| (static_cast<OCTAVE_TIME_T> (last_write_time.dwLowDateTime));
#else
file_stat fs = file_stat (filename);
m_time = fs.mtime ().unix_time ();
Expand Down
4 changes: 2 additions & 2 deletions liboctave/system/oct-time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<OCTAVE_TIME_T> (t.dwHighDateTime)) >> 32
| t.dwLowDateTime;
m_time = (static_cast<OCTAVE_TIME_T> (t.dwHighDateTime)) << 32
| (static_cast<OCTAVE_TIME_T> (t.dwLowDateTime));
}
#endif

Expand Down

0 comments on commit 26776f9

Please sign in to comment.