From f5702b311865a7ef671b789b0f2207bd171c7234 Mon Sep 17 00:00:00 2001 From: wpk Date: Thu, 29 Dec 2016 13:44:19 +0100 Subject: [PATCH] Add support for '-' as a filename for stdin/stdout --- fstrm/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fstrm/file.c b/fstrm/file.c index 5a17c0957..6c6d11dc6 100644 --- a/fstrm/file.c +++ b/fstrm/file.c @@ -55,7 +55,10 @@ fstrm__file_op_open(void *obj) { struct fstrm__file *f = obj; if (f->fp == NULL && f->file_path != NULL) { - f->fp = fopen(f->file_path, f->file_mode); + if (!strcmp(f->file_path, "-")) + f->fp = f->file_mode[0] == 'r' ? stdin : stdout; + else + f->fp = fopen(f->file_path, f->file_mode); if (f->fp == NULL) return fstrm_res_failure; return fstrm_res_success;