DELETE command
[rxpd] / src / rxpd_file.c
index 0a78c72..d49644b 100644 (file)
@@ -57,18 +57,18 @@ rxpd_file_new (struct rxpd_base* base, const char* filename)
 }
 
 void
-rxpd_file_delete (PSplay f)
+rxpd_file_delete (struct rxpd_file* self)
 {
-  if (f)
+  if (self)
     {
-      struct rxpd_file* file = (struct rxpd_file*)f;
-      LLIST_WHILE_HEAD (&file->rules, n)
+      LLIST_WHILE_HEAD (&self->rules, n)
         {
           struct rxpd_rule* node = (struct rxpd_rule*)n;
           rxpd_rule_delete (node);
         }
-      free ((void*)file->filename);
-      free (f);
+      psplay_remove (&self->base->files, &self->node);
+      free ((void*)self->filename);
+      free (self);
     }
 }
 
@@ -127,7 +127,12 @@ rxpd_file_save (struct rxpd_file* self)
       LLIST_FOREACH (&self->rules, n)
         {
           struct rxpd_rule* node = (struct rxpd_rule*)n;
-          fprintf (f, "%s\n", node->string);
+          if (node->atime != (time_t)-1)
+            fprintf (f, "%ld:%s\n", node->atime, node->string);
+          else if (*node->string != '#')
+            fprintf (f, ":%s\n", node->string);
+          else
+            fprintf (f, "%s\n", node->string);
         }
 
       fclose (f);