I want to implement a live reload of certain files. I assume that it is possible to somehow read the last-modified time of a file. That could be compared against the last time I loaded that file. I would keep the latter in memory.
How can I find out whether a file was modified since a given time? The solution should work on Windows, Mac and Linux.
Update: It seems like my question has raised some misinterpretations. To make thinks clear, I am asking about finding out if a file was modified in general. Using the last-modified time was just what first came to my mind, but I am open minded to any other solution! Unfortunately I cannot afford to open each file and compare its content, since we are talking about all textures of a video game.
To really know if the file has changed, you'd need to store a hash of the files (md5sum, sha256, etc) and for the comparison re-hash and compare the values of the 2 hashes.
have a look at Boost.FileSystem, std::time_t last_write_time(const path&)
. Disclaimer: I'm not sure how portable this concept is
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With