src/utils/udcCleanup/udcCleanup.c 1.2
1.2 2009/02/10 02:39:23 kent
Adding -test flag
Index: src/utils/udcCleanup/udcCleanup.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/utils/udcCleanup/udcCleanup.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/utils/udcCleanup/udcCleanup.c 7 Feb 2009 17:42:08 -0000 1.1
+++ src/utils/udcCleanup/udcCleanup.c 10 Feb 2009 02:39:23 -0000 1.2
@@ -7,31 +7,40 @@
#include "udc.h"
static char const rcsid[] = "$Id$";
+char *cacheDir = NULL;
+boolean testOnly = FALSE;
+
void usage()
/* Explain usage and exit. */
{
errAbort(
"udcCleanup - Clean up old unused files in udcCache.\n"
"usage:\n"
- " udcCleanup cacheDir maxUnusedDays\n"
+ " udcCleanup maxUnusedDays\n"
"example:\n"
- " udcCleanup /tmp/udcCache 7.5"
+ " udcCleanup 7.5\n"
+ "options:\n"
+ " -cacheDir=dir use the indicated cache dir instead of the default (%s)\n"
+ " -test - don't actually clean up, but do still figure cleanup bytes\n"
+ , udcDefaultDir()
);
}
static struct optionSpec options[] = {
+ {"cacheDir", OPTION_STRING},
+ {"test", OPTION_BOOLEAN},
{NULL, 0},
};
-void doCleanup(char *cacheDir, char *dayString)
+void doCleanup(char *dayString)
/* doCleanup - Clean up old unused files in udcCache.. */
{
double maxDays = atof(dayString);
if (maxDays <= 0)
errAbort("The maxUnusedDays needs to be a positive value");
-bits64 cleanedBytes = udcCleanup(cacheDir, maxDays);
+bits64 cleanedBytes = udcCleanup(cacheDir, maxDays, testOnly);
printf("Cleaned up ");
printLongWithCommas(stdout, cleanedBytes);
printf(" bytes from files unused for %s days\n", dayString);
}
@@ -39,9 +48,11 @@
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
-if (argc != 3)
+if (argc != 2)
usage();
-doCleanup(argv[1], argv[2]);
+cacheDir = optionVal("cacheDir", udcDefaultDir());
+testOnly = optionExists("test");
+doCleanup(argv[1]);
return 0;
}