Mercurial > octave
changeset 32097:53e15e754725
file_time: Notice file updates of files in root directory on Windows (bug #59711).
* liboctave/system/oct-time.cc (file_time::file_time): It's not possible to get
a file handle for the root directory of a drive on Windows. Instead use
GetFileAttributesExW to check if files in any folder (including the root
directory) have been updated.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 22 May 2023 17:09:25 +0200 |
parents | 501730f07abc |
children | d039fbf92297 |
files | liboctave/system/oct-time.cc |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/oct-time.cc Sun May 21 12:15:37 2023 +0200 +++ b/liboctave/system/oct-time.cc Mon May 22 17:09:25 2023 +0200 @@ -393,16 +393,20 @@ { #if defined (OCTAVE_USE_WINDOWS_API) std::wstring wfull_name = sys::u8_to_wstring (filename); - HANDLE h_file - = CreateFile (wfull_name.c_str (), GENERIC_READ, - FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, - nullptr); - FILETIME last_access_time; - GetFileTime (h_file, nullptr, &last_access_time, nullptr); + WIN32_FILE_ATTRIBUTE_DATA file_attributes; + + if (! GetFileAttributesExW (wfull_name.c_str (), GetFileExInfoStandard, + &file_attributes)) + { + m_time = 0; + return; + } + + FILETIME last_write_time = file_attributes.ftLastWriteTime; m_time - = (static_cast<OCTAVE_TIME_T> (last_access_time.dwHighDateTime)) >> 32 - | last_access_time.dwLowDateTime; + = (static_cast<OCTAVE_TIME_T> (last_write_time.dwHighDateTime)) >> 32 + | last_write_time.dwLowDateTime; #else file_stat fs = file_stat (filename); m_time = fs.mtime ().unix_time ();