+ /* If the file path has the prefix home, tmp or usr it was on the local file system and has been deleted. Ignore it. */
+ if (!g_str_has_prefix(buffer2, "/home") && !g_str_has_prefix(buffer2, "/tmp") && !g_str_has_prefix(buffer2, "/usr"))
+ {
+ /* The file was on a mounted drive and either has been deleted or the drive is not mounted */
+ struct mntent *mount_entry;
+ FILE *mount_entries;
+ gboolean found = FALSE;
+
+ mount_entries = setmntent("/proc/mounts", "r");
+ if (mount_entries == nullptr)
+ {
+ /* It is assumed this will never fail */
+ perror("setmntent");
+ exit(1);
+ }
+
+ while (nullptr != (mount_entry = getmntent(mount_entries)))
+ {
+ if (g_strcmp0(mount_entry->mnt_dir, G_DIR_SEPARATOR_S) != 0)
+ {
+ if (g_str_has_prefix(buffer2, mount_entry->mnt_dir))
+ {
+ log_printf("%s was a file on a mounted filesystem but has been deleted: %s", buffer2, cd->name);
+ found = TRUE;
+ break;
+ }
+ }
+ }
+ endmntent(mount_entries);
+
+ if (!found)
+ {
+ log_printf("%s is a file on an unmounted filesystem: %s", buffer2, cd->path);
+ gchar *text = g_strdup_printf(_("This Collection cannot be opened because it contains a link to a file on a drive which is not yet mounted.\n\nCollection: %s\nFile: %s\n"), cd->path, buffer2);
+ warning_dialog(_("Cannot open Collection"), text, GQ_ICON_DIALOG_WARNING, nullptr);
+ g_free(text);
+
+ collection_window_close_by_collection(cd);
+ success = FALSE;
+ break;
+ }
+ }
+ else
+ {
+ log_printf("%s was a file on local filesystem but has been deleted: %s", buffer2, cd->name);
+ }
+