Skip to content

Commit

Permalink
Add support for '-' as a filename for stdin/stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk committed Dec 29, 2016
1 parent 73d0ad8 commit f5702b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fstrm/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f5702b3

Please sign in to comment.