comparison files.c @ 113:1e7144176a42

Print a warning if we get an unexpected error trying to open a file.
author David A. Holland
date Tue, 11 Jun 2013 13:55:09 -0400
parents 2b0b61fd1a36
children 1cda505ddc78
comparison
equal deleted inserted replaced
112:2b0b61fd1a36 113:1e7144176a42
31 #include <stdio.h> 31 #include <stdio.h>
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <string.h> 33 #include <string.h>
34 #include <unistd.h> 34 #include <unistd.h>
35 #include <fcntl.h> 35 #include <fcntl.h>
36 #include <errno.h>
36 #include <err.h> 37 #include <err.h>
37 38
38 #include "array.h" 39 #include "array.h"
39 #include "mode.h" 40 #include "mode.h"
40 #include "place.h" 41 #include "place.h"
324 325
325 /* XXX check for non-regular files */ 326 /* XXX check for non-regular files */
326 327
327 fd = open(file, O_RDONLY); 328 fd = open(file, O_RDONLY);
328 if (fd < 0) { 329 if (fd < 0) {
330 if (errno != ENOENT && errno != ENOTDIR) {
331 warn("%s", file);
332 }
329 return -1; 333 return -1;
330 } 334 }
331 335
332 return fd; 336 return fd;
333 } 337 }