Boost C++ Libraries: Ticket #11037: last_write_time doesn't work on Windows on files with custom access rights https://svn.boost.org/trac10/ticket/11037 <p> last_write_time uses <a class="missing wiki">CreateFile</a> 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 <a class="missing wiki">FindFirstFile</a>. </p> <p> Here's an example based on the answer from <a class="missing wiki">StackOverflow</a> by Hans Passant: </p> <p> std::size_t last_write_time(boost::filesystem::path const &amp; path) { </p> <blockquote> <p> WIN32_FIND_DATAW info; auto hdl = FindFirstFileW(path.wstring().c_str(), &amp;info); if (hdl == INVALID_HANDLE_VALUE) return std::time_t(-1); std::time_t retval = to_time_t(info.ftLastWriteTime); <a class="missing wiki">FindClose</a>(hdl); <em> better use BOOST_SCOPE_EXIT two lines higher return retval; </em></p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11037 Trac 1.4.3 anonymous Mon, 16 Feb 2015 16:14:47 GMT <link>https://svn.boost.org/trac10/ticket/11037#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11037#comment:1</guid> <description> <p> Sorry, I've been expecting Markdown, not <a class="wiki" href="https://svn.boost.org/trac10/wiki/WikiFormatting">WikiFormatting</a>. Anyway, code is still pretty readable :) </p> </description> <category>Ticket</category> </item> </channel> </rss>