comparison ffstools/cal2text/mkdir.c @ 142:d41edd329670

fc-cal2text utility written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 27 Feb 2017 03:37:11 +0000
parents
children
comparison
equal deleted inserted replaced
141:6b01d4ef85c3 142:d41edd329670
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6
7 mkdir_existok(pathname)
8 char *pathname;
9 {
10 int rc;
11 struct stat st;
12
13 rc = stat(pathname, &st);
14 if (rc < 0) {
15 rc = mkdir(pathname, 0777);
16 if (rc < 0) {
17 perror(pathname);
18 exit(1);
19 }
20 return(0);
21 } else {
22 if (S_ISDIR(st.st_mode))
23 return(0);
24 else {
25 fprintf(stderr,
26 "error: %s already exists and is not a directory\n",
27 pathname);
28 exit(1);
29 }
30 }
31 }