- shared_ptr<const Image> image = load_image_raw(pathname);
- if (image == nullptr) {
- fprintf(stderr, "Couldn't load image, leaving the old in place.\n");
- continue;
+
+ for (const auto &pathname_and_timespec : images_to_check) {
+ const string pathname = pathname_and_timespec.first;
+ const timespec last_modified = pathname_and_timespec.second;
+
+ if (stat(pathname.c_str(), &buf) != 0) {
+ fprintf(stderr, "%s: Couldn't check for new version, leaving the old in place.\n", pathname.c_str());
+ continue;
+ }
+ if (buf.st_mtim.tv_sec == last_modified.tv_sec &&
+ buf.st_mtim.tv_nsec == last_modified.tv_nsec) {
+ // Not changed.
+ continue;
+ }
+
+ shared_ptr<const Image> image = load_image_raw(pathname);
+ if (image == nullptr) {
+ fprintf(stderr, "Couldn't load image, leaving the old in place.\n");
+ continue;
+ }
+
+ unique_lock<mutex> lock(all_images_lock);
+ all_images[pathname] = image;