From 0f8ec41b0ae522b73085fa1662461e6351ba7e54 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 13 Feb 2005 05:58:45 +0000 Subject: moving to auth --- src/cmd/secstore/dirls.c | 87 ------------------------------------------------ 1 file changed, 87 deletions(-) delete mode 100644 src/cmd/secstore/dirls.c (limited to 'src/cmd/secstore/dirls.c') diff --git a/src/cmd/secstore/dirls.c b/src/cmd/secstore/dirls.c deleted file mode 100644 index b4479413..00000000 --- a/src/cmd/secstore/dirls.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include -#include -#include -#include "SConn.h" - -static long -ls(char *p, Dir **dirbuf) -{ - int fd; - long n; - Dir *db; - - if((db = dirstat(p)) == nil || - !(db->qid.type & QTDIR) || - (fd = open(p, OREAD)) < 0 ) - return -1; - free(db); - n = dirreadall(fd, dirbuf); - close(fd); - return n; -} - -static uchar* -sha1file(char *pfx, char *nm) -{ - int n, fd, len; - char *tmp; - uchar buf[8192]; - static uchar digest[SHA1dlen]; - DigestState *s; - - len = strlen(pfx)+1+strlen(nm)+1; - tmp = emalloc(len); - snprint(tmp, len, "%s/%s", pfx, nm); - if((fd = open(tmp, OREAD)) < 0){ - free(tmp); - return nil; - } - free(tmp); - s = nil; - while((n = read(fd, buf, sizeof buf)) > 0) - s = sha1(buf, n, nil, s); - close(fd); - sha1(nil, 0, digest, s); - return digest; -} - -static int -compare(Dir *a, Dir *b) -{ - return strcmp(a->name, b->name); -} - -/* list the (name mtime size sum) of regular, readable files in path */ -char * -dirls(char *path) -{ - char *list, *date, dig[30], buf[128]; - int m, nmwid, lenwid; - long i, n, ndir, len; - Dir *dirbuf; - - if(path==nil || (ndir = ls(path, &dirbuf)) < 0) - return nil; - - qsort(dirbuf, ndir, sizeof dirbuf[0], (int (*)(const void *, const void *))compare); - for(nmwid=lenwid=i=0; i nmwid) - nmwid = m; - snprint(buf, sizeof(buf), "%ulld", dirbuf[i].length); - if((m = strlen(buf)) > lenwid) - lenwid = m; - } - for(list=nil, len=0, i=0; i