16 lines
289 B
C
16 lines
289 B
C
#include "file_open.h"
|
|
|
|
FILE *file_open(const char *prog, const char *path, const char *mode) {
|
|
if (!strcmp(path, "-"))
|
|
return stdin;
|
|
|
|
FILE *fp = fopen(path, mode);
|
|
if (fp == NULL) {
|
|
if (prog)
|
|
fprintf(stderr, "%s: %s\n", prog, strerror(errno));
|
|
|
|
return NULL;
|
|
}
|
|
|
|
return fp;
|
|
}
|