aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/mkdir.C
blob: 5bfa67735a08d26d1f5ed4952ae4bb3e4cd26c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <u.h>
#include <libc.h>

void
main(int argc, char *argv[])
{
	int i, f;
	char *e;

	e = nil;
	for(i=1; i<argc; i++){
		if(access(argv[i], 0) == AEXIST){
			fprint(2, "mkdir: %s already exists\n", argv[i]);
			e = "error";
			continue;
		}
		f = create(argv[i], OREAD, DMDIR | 0777L);
		if(f < 0){
			fprint(2, "mkdir: can't create %s: %r\n", argv[i]);
			e = "error";
			continue;
		}
		close(f);
	}
	exits(e);
}