Subject: [Boost-bugs] [Boost C++ Libraries] #11037: last_write_time doesn't work on Windows on files with custom access rights
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-02-16 16:07:02
#11037: last_write_time doesn't work on Windows on files with custom access rights
------------------------------+------------------------
Reporter: anonymous | Owner: bemandawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
last_write_time uses CreateFile internally with some minimal rights.
Anyway, it doesn't have rights to read the last write time of "System
Volume Information", even though such data are available i.e. for Windows
Explorer. The right way to get descriptor for such file or folder is
FindFirstFile.
Here's an example based on the answer from StackOverflow by Hans Passant:
std::size_t last_write_time(boost::filesystem::path const & path) {
WIN32_FIND_DATAW info;
auto hdl = FindFirstFileW(path.wstring().c_str(), &info);
if (hdl == INVALID_HANDLE_VALUE) return std::time_t(-1);
std::time_t retval = to_time_t(info.ftLastWriteTime);
FindClose(hdl); // better use BOOST_SCOPE_EXIT two lines higher
return retval;
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11037> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC