| 486 | } |
| 487 | |
| 488 | static bool verify_optiondir(const char *directory) |
| 489 | { |
| 490 | struct stat buf; |
| 491 | |
| 492 | if (stat(directory, &buf) < 0) |
| 493 | { |
| 494 | /* It may be okay if the directory does not exist */ |
| 495 | |
| 496 | /* It may be okay if the file does not exist */ |
| 497 | |
| 498 | int errcode = errno; |
| 499 | if (errcode == ENOENT) |
| 500 | { |
| 501 | debug("verify_optiondir: stat of %s failed: %s\n", |
| 502 | directory, strerror(errno)); |
| 503 | return false; |
| 504 | } |
| 505 | else |
| 506 | { |
| 507 | fprintf(stderr, "ERROR: stat of %s failed: %s\n", |
| 508 | directory, strerror(errno)); |
| 509 | exit(EXIT_FAILURE); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | if (!S_ISDIR(buf.st_mode)) |
| 514 | { |
| 515 | fprintf(stderr, "ERROR: %s exists but is not a directory\n", |
| 516 | directory); |
| 517 | exit(EXIT_FAILURE); |
| 518 | } |
| 519 | |
| 520 | return true; |
| 521 | } |
| 522 | |
| 523 | static bool verify_file(const char *path) |
| 524 | { |