Charmap work
[idzebra-moved-to-github.git] / index / dirs.c
index b26ff3d..27e96b9 100644 (file)
@@ -1,10 +1,20 @@
 /*
- * Copyright (C) 1994-1995, Index Data I/S 
+ * Copyright (C) 1994-1996, Index Data I/S 
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dirs.c,v $
- * Revision 1.7  1996-03-21 14:50:09  adam
+ * Revision 1.10  1996-06-04 10:18:58  adam
+ * Minor changes - removed include of ctype.h.
+ *
+ * Revision 1.9  1996/04/23  12:39:07  adam
+ * Bug fix: In function dirs_del dict_delete is used to remove a file
+ * rather than a bogus dict_insert.
+ *
+ * Revision 1.8  1996/04/12  07:02:21  adam
+ * File update of single files.
+ *
+ * Revision 1.7  1996/03/21 14:50:09  adam
  * File update uses modify-time instead of change-time.
  *
  * Revision 1.6  1996/02/02  13:44:43  adam
@@ -31,7 +41,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <ctype.h>
 
 #include <alexutil.h>
 #include "index.h"
@@ -104,6 +113,34 @@ struct dirs_info *dirs_open (Dict dict, const char *rep)
     return p;
 }
 
+struct dirs_info *dirs_fopen (Dict dict, const char *path)
+{
+    struct dirs_info *p;
+    struct dirs_entry *entry;
+    char *info;
+
+    p = xmalloc (sizeof(*p));
+    p->dict = dict;
+    *p->prefix = '\0';
+    p->entries = xmalloc (sizeof(*p->entries));
+    p->no_read = 0;
+    p->no_cur = 0;
+    p->no_max = 2;
+
+    entry = p->entries;
+    info = dict_lookup (dict, path);
+    if (info && info[0] == sizeof(entry->sysno)+sizeof(entry->mtime))
+    {
+        strcpy (entry->path, path); 
+        entry->kind = dirs_file;
+        memcpy (&entry->sysno, info+1, sizeof(entry->sysno));
+        memcpy (&entry->mtime, info+1+sizeof(entry->sysno), 
+                sizeof(entry->mtime));
+        p->no_cur++;
+    }
+    return p;
+}
+
 struct dirs_entry *dirs_read (struct dirs_info *p)
 {
     int before = 0, after = p->no_max+1;
@@ -163,12 +200,10 @@ void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime)
 void dirs_del (struct dirs_info *p, const char *src)
 {
     char path[256];
-    char info[2];
 
     sprintf (path, "%s%s", p->prefix, src);
     logf (LOG_DEBUG, "dirs_del %s", path);
-    info[0] = 'r';
-    dict_insert (p->dict, path, 1, info);
+    dict_delete (p->dict, path);
 }
 
 void dirs_free (struct dirs_info **pp)