fixed
This commit is contained in:
parent
ec265a4c23
commit
ad0d7d25ff
5 changed files with 171 additions and 109 deletions
16
libmu/file_open.c
Normal file
16
libmu/file_open.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#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;
|
||||
}
|
9
libmu/file_open.h
Normal file
9
libmu/file_open.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef _FILE_OPEN_H
|
||||
#define _FILE_OPEN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
FILE *file_open(const char *prog, const char *path, const char *mode);
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue