Skip to content

Commit

Permalink
Merge pull request #28 from wupeka/master
Browse files Browse the repository at this point in the history
Add support for '-' as a filename for stdin/stdout
  • Loading branch information
cmikk authored Jan 12, 2017
2 parents db5807e + f5702b3 commit f6e2fd5
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 f6e2fd5

Please sign in to comment.