summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/internal/slibtool_libmeta_impl.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/internal/slibtool_libmeta_impl.c b/src/internal/slibtool_libmeta_impl.c
index c8dd291..bc4fca2 100644
--- a/src/internal/slibtool_libmeta_impl.c
+++ b/src/internal/slibtool_libmeta_impl.c
@@ -4,10 +4,12 @@
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <slibtool/slibtool.h>
+#include "slibtool_dprintf_impl.h"
#include "slibtool_errinfo_impl.h"
#include "slibtool_metafile_impl.h"
@@ -20,7 +22,7 @@ static int slbt_create_default_library_wrapper(
char * solnk)
{
int ret;
- FILE * fout;
+ int fdout;
const char * header;
const char * base;
bool fnover;
@@ -33,7 +35,11 @@ static int slbt_create_default_library_wrapper(
(void)ectx;
/* create */
- if (!(fout = fopen(dctx->cctx->output,"w")))
+ if ((fdout = openat(
+ AT_FDCWD,
+ dctx->cctx->output,
+ O_RDWR|O_CREAT|O_TRUNC,
+ 0644)) < 0)
return SLBT_SYSTEM_ERROR(dctx);
/* version info */
@@ -54,7 +60,7 @@ static int slbt_create_default_library_wrapper(
base = "";
/* wrapper content */
- ret = fprintf(fout,
+ ret = slbt_dprintf(fdout,
"# %s%s"
"# Generated by %s (slibtool %d.%d.%d)\n"
"# [commit reference: %s]\n\n"
@@ -115,9 +121,9 @@ static int slbt_create_default_library_wrapper(
/* libdir */
dctx->cctx->rpath ? dctx->cctx->rpath : "");
- return (ret <= 0) || fclose(fout)
- ? SLBT_SYSTEM_ERROR(dctx)
- : 0;
+ close(fdout);
+
+ return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0;
}
static int slbt_create_compatible_library_wrapper(