예제 #1
0
struct fileInfo *listDirX(char *dir, char *pattern, boolean fullPath)
/* Return list of files matching wildcard pattern with
 * extra info. If full path is true then the path will be
 * included in the name of each file. */
{
return listDirXExt(dir, pattern, fullPath, FALSE);
}
예제 #2
0
void nukeOldCnfs(char *homeDir)
/* Remove .hgsql.cnf-* files older than a month */
{
// ignoreStatFailures must be TRUE due to race condition between two hgsql
// commands might trying to purge the same file.
struct fileInfo *file, *fileList = listDirXExt(homeDir, ".hgsql.cnf-*", FALSE, TRUE);
time_t now = time(0);
for (file = fileList; file != NULL; file = file->next)
    {
    if ((file->statErrno == 0) && (difftime(now, file->lastAccess) >  30 * 24 * 60 * 60))  // 30 days in seconds.
	{
	char homePath[256];
	safef(homePath, sizeof homePath, "%s/%s", homeDir, file->name);
	remove(homePath);
	}
    }
slFreeList(&fileList);
}