+static char *filestore_lookup_last(gpointer store, const char *prefix)
+{
+ char *last = NULL;
+ GDir *dir = g_dir_open(".", 0, NULL);
+ if (dir == NULL) {
+ g_warning("Unable to open directory for listing");
+ return NULL;
+ }
+
+ const gchar *file;
+ while ((file = g_dir_read_name(dir)) != NULL) {
+ if (strncmp(file, prefix, strlen(prefix)) == 0) {
+ if (last == NULL || strcmp(file, last) > 0) {
+ g_free(last);
+ last = g_strdup(file);
+ }
+ }
+ }
+ g_dir_close(dir);
+
+ return last;
+}
+