+
+static void repositoryExtract (ZebraHandle zh,
+ int deleteFlag, const char *path)
+{
+ struct stat sbuf;
+ char src[1024];
+ int ret;
+
+ assert (path);
+
+ if (zh->path_reg && !yaz_is_abspath(path))
+ {
+ strcpy (src, zh->path_reg);
+ strcat (src, "/");
+ }
+ else
+ *src = '\0';
+ strcat (src, path);
+ ret = zebra_file_stat (src, &sbuf, zh->m_follow_links);
+
+ strcpy (src, path);
+
+ if (ret == -1)
+ yaz_log (LOG_WARN|LOG_ERRNO, "Cannot access path %s", src);
+ else if (S_ISREG(sbuf.st_mode))
+ fileExtract (zh, NULL, src, deleteFlag);
+ else if (S_ISDIR(sbuf.st_mode))
+ repositoryExtractR (zh, deleteFlag, src, 0);
+ else
+ yaz_log (LOG_WARN, "Skipping path %s", src);
+}
+
+static void repositoryExtractG (ZebraHandle zh, const char *path,
+ int deleteFlag)
+{
+ if (!strcmp(path, "") || !strcmp(path, "-"))
+ {
+ char src[1024];
+
+ while (scanf ("%1020s", src) == 1)
+ repositoryExtract (zh, deleteFlag, src);
+ }
+ else
+ repositoryExtract (zh, deleteFlag, path);
+}
+
+void repositoryUpdate (ZebraHandle zh, const char *path)
+{
+ assert (path);
+ if (zh->m_record_id && !strcmp (zh->m_record_id, "file"))
+ {
+ Dict dict;
+ if (!(dict = dict_open_res (zh->reg->bfs, FMATCH_DICT, 50,
+ zh->m_flag_rw, 0, zh->res)))
+ {
+ yaz_log (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
+ return ;
+ }
+ if (!strcmp(path, "") || !strcmp(path, "-"))
+ {
+ char src[1024];
+ while (scanf ("%s", src) == 1)
+ fileUpdate (zh, dict, src);
+ }
+ else
+ fileUpdate (zh, dict, path);
+ dict_close (dict);
+ }
+ else
+ repositoryExtractG (zh, path, 0);
+}
+
+void repositoryDelete (ZebraHandle zh, const char *path)
+{
+ assert (path);
+ repositoryExtractG (zh, path, 1);
+}
+