Boost C++ Libraries: Ticket #5850: last_write_time on Windows may not work on SMB2-network-mounted drive https://svn.boost.org/trac10/ticket/5850 <p> Consider the following logical operation against a file on a network-mounted drive served over SMB2: </p> <ol><li>fopen("r+b")/fwrite/fclose a file. </li><li>boost::filesystem::last_write_time(file, some other specific time) </li><li>fopen("rb")/fclose a file. </li></ol><p> As soon as the file is opened in step 3, it appears that the SMB2/redirector actually closes the file and "flushes" its pending write in service of step 1. This has the effect of overwriting the time modification in step 2. </p> <p> I believe this is happening because boost's non-POSIX/Windows implementation of last_write_time uses <a class="missing wiki">CreateFile</a>() and asks only for FILE_WRITE_ATTRIBUTES. Using GENERIC_WRITE appears to work correctly. </p> <p> Also note, calling utime() instead of boost::filesystem::last_write_time() works correctly. </p> <p> Please see attached test code demonstrating boost's failure, utime()'s success, and native API workaround. </p> <p> Please feel free to contact me for follow up. Thanks, -Ken </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5850 Trac 1.4.3 Ken Harris <kharris@…> Wed, 31 Aug 2011 15:22:44 GMT attachment set https://svn.boost.org/trac10/ticket/5850 https://svn.boost.org/trac10/ticket/5850 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bbug.cpp</span> </li> </ul> Ticket Beman Dawes Tue, 11 Oct 2011 12:21:05 GMT status changed https://svn.boost.org/trac10/ticket/5850#comment:1 https://svn.boost.org/trac10/ticket/5850#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket