Introduction
Introduction Statistics Contact Development Disclaimer Help
file.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
file.c (1316B)
---
1 #include "mk.h"
2
3 /* table-driven version in bootes dump of 12/31/96 */
4
5 long
6 mtime(char *name)
7 {
8 return mkmtime(name);
9 }
10
11 long
12 timeof(char *name, int force)
13 {
14 Symtab *sym;
15 long t;
16
17 if(utfrune(name, '('))
18 return atimeof(force, name); /* archive */
19
20 if(force)
21 return mtime(name);
22
23
24 sym = symlook(name, S_TIME, 0);
25 if (sym)
26 return sym->u.value;
27
28 t = mtime(name);
29 if(t == 0)
30 return 0;
31
32 symlook(name, S_TIME, (void*)t); /* install time …
33 return t;
34 }
35
36 void
37 touch(char *name)
38 {
39 Bprint(&bout, "touch(%s)\n", name);
40 if(nflag)
41 return;
42
43 if(utfrune(name, '('))
44 atouch(name); /* archive */
45 else if(chgtime(name) < 0) {
46 fprint(2, "%s: %r\n", name);
47 Exit();
48 }
49 }
50
51 void
52 delete(char *name)
53 {
54 if(utfrune(name, '(') == 0) { /* file */
55 if(remove(name) < 0)
56 fprint(2, "remove %s: %r\n", name);
57 } else
58 fprint(2, "hoon off; mk can'tdelete archive members\n");
59 }
60
61 void
62 timeinit(char *s)
63 {
64 long t;
65 char *cp;
66 Rune r;
67 int c, n;
68
69 t = time(0);
70 while (*s) {
71 cp = s;
72 do{
73 n = chartorune(&r, s);
74 if (r == ' ' || r == ',' || r == '\n')
75 break;
76 s += n;
77 } while(*s);
78 c = *s;
79 *s = 0;
80 symlook(strdup(cp), S_TIME, (void *)t)->u.value = t;
81 if (c)
82 *s++ = c;
83 while(*s){
84 n = chartorune(&r, s);
85 if(r != ' ' && r != ',' && r != '\n')
86 break;
87 s += n;
88 }
89 }
90 }
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.