# HG changeset patch # User Markus Mützel # Date 1684768165 -7200 # Node ID 53e15e7547256828395299f28820806ec83d86ea # Parent 501730f07abce9e5924258297d5b1b5bf1658e21 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. diff -r 501730f07abc -r 53e15e754725 liboctave/system/oct-time.cc --- 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 (last_access_time.dwHighDateTime)) >> 32 - | last_access_time.dwLowDateTime; + = (static_cast (last_write_time.dwHighDateTime)) >> 32 + | last_write_time.dwLowDateTime; #else file_stat fs = file_stat (filename); m_time = fs.mtime ().unix_time ();