comparison ffstools/cal2text/dircheck.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 /*
2 * Both arguments to fc-cal2text must name directories that already exist.
3 * Here we implement the check for this requirement.
4 */
5
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 check_directory_exists(pathname)
13 char *pathname;
14 {
15 struct stat st;
16
17 if (stat(pathname, &st) < 0) {
18 perror(pathname);
19 exit(1);
20 }
21 if (!S_ISDIR(st.st_mode)) {
22 fprintf(stderr, "error: %s is not a directory\n", pathname);
23 exit(1);
24 }
25 return(0);
26 }