about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTVMSUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation/HTVMSUtils.c')
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index d2e981a9..7f49ff67 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -30,6 +30,7 @@
 #include <starlet.h>
 #include <rmsdef.h>
 
+#include <LYUtils.h>
 #include <LYLeaks.h>
 
 #define FREE(x) if (x) {free(x); x = NULL;}
@@ -1245,3 +1246,33 @@ PUBLIC int HTVMSBrowseDir ARGS4(
     return HT_LOADED;
 
 } /* End of directory reading section */
+
+/*
+ * Remove all versions of the given file.  We assume there are no permissions
+ * problems, since we do this mainly for removing temporary files.
+ */
+int HTVMS_remove(char *filename)
+{
+    int code = remove(filename);	/* return the first status code */
+    while (remove(filename) == 0)
+	;
+    return code;
+}
+
+/*
+ * Remove all older versions of the given file.  We may fail to remove some
+ * version due to permissions -- the loop stops either at that point, or when
+ * we run out of older versions to remove.
+ */
+void HTVMS_purge(char *filename)
+{
+    char *older_file = 0;
+
+    StrAllocCopy(older_file, filename);
+    StrAllocCat(older_file, ";-1");
+
+    while (remove(older_file) == 0)
+	;
+
+    FREE(older_file);
+}