From 3d38ce6b746e9d6f4e0b7dc251d88dba78fb0a47 Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 2 Aug 2018 18:09:21 +0000 Subject: internals: mdso_create_output(): prepare for removal of stream objects. --- src/helper/mdso_create_output.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/helper/mdso_create_output.c b/src/helper/mdso_create_output.c index 484e59b..f94524b 100644 --- a/src/helper/mdso_create_output.c +++ b/src/helper/mdso_create_output.c @@ -15,22 +15,32 @@ #include "mdso_driver_impl.h" #include "mdso_errinfo_impl.h" -static FILE * mdso_create_output( +static int mdso_create_output( const struct mdso_driver_ctx * dctx, const char * name) { - int fddst; - int fdout; - FILE * fout; + int fddst; + int fdout; fddst = mdso_driver_fddst(dctx); if ((fdout = openat(fddst,name, O_CREAT|O_TRUNC|O_WRONLY|O_NOCTTY|O_NOFOLLOW, - S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) { - MDSO_SYSTEM_ERROR(dctx); + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) + return MDSO_SYSTEM_ERROR(dctx); + + return fdout; +} + +static FILE * mdso_create_output_stream( + const struct mdso_driver_ctx * dctx, + const char * name) +{ + int fdout; + FILE * fout; + + if ((fdout = mdso_create_output(dctx,name)) < 0) return 0; - } if (!(fout = fdopen(fdout,"w"))) { close(fdout); @@ -45,7 +55,7 @@ FILE * mdso_create_archive( const struct mdso_driver_ctx * dctx, const char * arname) { - return mdso_create_output(dctx,arname); + return mdso_create_output_stream(dctx,arname); } FILE * mdso_create_asmsrc( @@ -53,7 +63,7 @@ FILE * mdso_create_asmsrc( const char * asmname) { return dctx->cctx->dstdir - ? mdso_create_output(dctx,asmname) + ? mdso_create_output_stream(dctx,asmname) : stdout; } @@ -61,5 +71,5 @@ FILE * mdso_create_object( const struct mdso_driver_ctx * dctx, const char * objname) { - return mdso_create_output(dctx,objname); + return mdso_create_output_stream(dctx,objname); } -- cgit v1.2.3