Introduction
Introduction Statistics Contact Development Disclaimer Help
dirstat.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
dirstat.c (551B)
---
1 #include <u.h>
2 #define NOPLAN9DEFINES
3 #include <libc.h>
4
5 #include <sys/stat.h>
6
7 extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*…
8
9 Dir*
10 dirstat(char *file)
11 {
12 struct stat lst;
13 struct stat st;
14 int nstr;
15 Dir *d;
16 char *str;
17
18 if(lstat(file, &lst) < 0)
19 return nil;
20 st = lst;
21 if((lst.st_mode&S_IFMT) == S_IFLNK)
22 stat(file, &st);
23
24 nstr = _p9dir(&lst, &st, file, nil, nil, nil);
25 d = mallocz(sizeof(Dir)+nstr, 1);
26 if(d == nil)
27 return nil;
28 str = (char*)&d[1];
29 _p9dir(&lst, &st, file, d, &str, str+nstr);
30 return d;
31 }
32
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.