+struct dirs_entry *dirs_read (struct dirs_info *p)
+{
+ int before = 0, after = p->no_max+1;
+
+ if (p->no_read < p->no_cur)
+ {
+ yaz_log (YLOG_DEBUG, "dirs_read %d. returns %s", p->no_read,
+ (p->entries + p->no_read)->path);
+ return p->last_entry = p->entries + (p->no_read++);
+ }
+ if (p->no_cur < p->no_max)
+ return p->last_entry = NULL;
+ if (p->nextpath_deleted)
+ {
+ p->no_cur = 0;
+ after = p->no_max;
+ }
+ else
+ {
+ p->no_cur = -1;
+ after = p->no_max + 1;
+ }
+ p->no_read = 1;
+ p->nextpath_deleted = 0;
+ yaz_log (YLOG_DEBUG, "dirs_read rescan %s", p->nextpath);
+ dict_scan (p->dict, p->nextpath, &before, &after, p, dirs_client_proc);
+ if (p->no_read <= p->no_cur)
+ return p->last_entry = p->entries;
+ return p->last_entry = NULL;
+}
+
+struct dirs_entry *dirs_last (struct dirs_info *p)
+{
+ return p->last_entry;
+}
+
+void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime)
+{
+ char path[DIRS_MAX_PATH];
+
+ sprintf (path, "%s%s", p->prefix, src);
+ yaz_log (YLOG_DEBUG, "dirs_mkdir %s", path);
+ if (p->rw)
+ dict_insert (p->dict, path, sizeof(mtime), &mtime);
+}
+
+void dirs_rmdir (struct dirs_info *p, const char *src)
+{
+ char path[DIRS_MAX_PATH];
+
+ sprintf (path, "%s%s", p->prefix, src);
+ yaz_log (YLOG_DEBUG, "dirs_rmdir %s", path);
+ if (p->rw)
+ dict_delete (p->dict, path);
+}
+
+void dirs_add (struct dirs_info *p, const char *src, SYSNO sysno, time_t mtime)
+{
+ char path[DIRS_MAX_PATH];
+ char info[16];
+
+ sprintf (path, "%s%s", p->prefix, src);
+ yaz_log (YLOG_DEBUG, "dirs_add %s", path);
+ memcpy (info, &sysno, sizeof(sysno));
+ memcpy (info+sizeof(sysno), &mtime, sizeof(mtime));
+ if (p->rw)
+ dict_insert (p->dict, path, sizeof(sysno)+sizeof(mtime), info);
+}
+
+void dirs_del (struct dirs_info *p, const char *src)
+{
+ char path[DIRS_MAX_PATH];
+
+ sprintf (path, "%s%s", p->prefix, src);
+ yaz_log (YLOG_DEBUG, "dirs_del %s", path);
+ if (p->rw)
+ {
+ if (!strcmp(path, p->nextpath))
+ p->nextpath_deleted = 1;
+ dict_delete (p->dict, path);
+ }
+}
+