
Is there a portable way to use the boost filesystem library to copy files and preserve mtimes? I am writing a tool that moves media files around and mtime can be significant when other sources of metadata are absent (like exif, iptc, xmp). It would be a bummer to have to add platform specific code to do that. Thanks, -Brad

On 01/23/2009 10:07 PM, Brad Schick wrote:
Is there a portable way to use the boost filesystem library to copy files and preserve mtimes? I am writing a tool that moves media files around and mtime can be significant when other sources of metadata are absent (like exif, iptc, xmp).
I'll answer my own question. Looking through the code I found that there are both read and write versions of 'last_write_time'. So I can read the source time and write it to the copy. That's in the docs also, but I didn't notice the write version. I still think it would be helpful if 'copy_file' took a bool to control write time preservation, since currently the default behavior is a bit unpredictable. On windows copy_file preserves mtime time, while under posix it does not. Looking at the code, it is obvious why since the posix copy_file just opens and writes the 'to' file directly. Optionally adding a utime call after the write would be handy (and the stat info from the source is already loaded). -Brad
participants (1)
-
Brad Schick